Getting day of week from date column in prestosql?
Asked Answered
F

2

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

Fannyfanon answered 28/8, 2019 at 20:50 Comment(0)
L
12

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
Littoral answered 28/8, 2019 at 21:20 Comment(0)
A
-1

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

Already answered 28/8, 2019 at 21:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.