6

I have a date column called day such as 2019/07/22 if I want to create a custom field that translates that date to the actual day of week it is such as Sunday or Monday how is this possible? I cant seem to find a method that works for presto sql.

Thanks for looking

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
Chris90
  • 1,868
  • 5
  • 20
  • 42

2 Answers2

11

You can use the format_datetime function to extract the day of week from a date or timestamp:

SELECT format_datetime(day, 'E')
FROM (
  VALUES DATE '2019-07-22'
) t(day)

produces:

 _col0
-------
 Mon

If you want the full name of the day, use format_datetime(day, 'EEEE'):

 _col0
-------
 Monday
Martin Traverso
  • 4,731
  • 15
  • 24
-1

You can try extract('day' from day ) as day_name.