postgresqldatepart

How can I get the day of the week for a given date in PostgreSQL?


I want to retrieve day of the week from the given date.

For example the date is: 2015-01-28 then it has to return Wednesday

My bad try:

select date_part('week',now()) as weekday;

The above script gives me only number of week but not the day of the week.


Solution

  • Try to_char():

    select to_char(now(), 'Day')