Teradata – Convert Timestamp to the Month of the Year

This one also surprises me that someone has not already posted.

The TD_Month_Of_Year function returns an integer value that need to converted to string value.  Careful when using this on a large data set, it can really slow down the response time.

select

td_month_of_year(current_date),

CASE

td_month_of_year(current_date)

WHEN 1 THEN 'January'

WHEN 2 THEN 'February'

WHEN 3 THEN 'March'

WHEN 4 THEN 'April'

WHEN 5 THEN 'May'

WHEN 6 THEN 'June'

WHEN 7 THEN 'July'

WHEN 8 THEN 'August'

WHEN 9 THEN 'September'

WHEN 10 THEN 'October'

WHEN 11 THEN 'November'

WHEN 12 THEN 'December'

END AS "Month of the Year"

Teradata Convert Timestamp to Month of the Year

Note: If you know of a native Teradata function that does this, please leave me note in the comments.

 

 

 

Comments are closed.