marcia12
marcia12

Reputation: 169

extract full month name from date in redshift

What a quick way to extract the full month name from a date in redshift.

2022-01-01 ->> January

Upvotes: 1

Views: 13137

Answers (2)

Michelle
Michelle

Reputation: 1

Use this formula for creating calculated field for the month name.

 [ifelse(
   month=1, "January",
   month=2, "February",
   month=3, "March",
   month=4, "April",
   month=5, "May",
   month=6, "June", 
   month=7, "July",
   month=8, "August",
   month=9, "September", 
   month=10, "October", 
   month=11, "November",
   month=12, "December", null
   ) ]

Upvotes: 0

Bill Weiner
Bill Weiner

Reputation: 11032

The to_char() function does this:

to_char(, 'Month')

For example

select to_char('2022-01-01'::date, 'Month');

produces 'January'.

Upvotes: 3

Related Questions