How to get month name from date in Presto

stack_pointer is EXTINCT picture stack_pointer is EXTINCT · Nov 20, 2017 · Viewed 14.8k times · Source

I use Presto and I do not know the function to get MONTH's name from a date column. I can get MONTH number using MONTH(<date>) function but I'm not able to get MONTH name.

I've seen ways where a list of month names is manually created and the number is matched over with the list to obtain the name. Is there a better approach to use any known function in Presto?

Answer

Kai Sasaki picture Kai Sasaki · Nov 24, 2017

As commented, Presto provides date_format function which is compatible with MySQL one. %M will tell you the exact month name of your timestamp. For example:

SELECT date_format(timestamp '2017-11-21 12:00:00', '%M') month_name