Amazon Redshift return name of day
Asked Answered
P

2

8

I am trying to get the name of the day of a specific date. For example for the date "11/22/2019" I want the result to be "Friday"

I use Amazon Redshift.

Any ideas?

Thanks

Plethora answered 22/11, 2019 at 19:19 Comment(0)
S
10

You can use to_char():

select to_char(datecol, 'Day')

Note that this value is padded to 9 characters, so for most weekdays, it will end in a bunch of spaces.

Sublimation answered 22/11, 2019 at 19:21 Comment(0)
D
1

To avoid empty space in the output of 'select to_char(current_date, 'Day');' and to get the exact day name you can use the below query.

select trim(' ' FROM to_char(current_date, 'Day'));

Dovetail answered 29/6, 2021 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.