Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL 9.3 : Get day of the week

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.

like image 994
MAK Avatar asked Jan 28 '15 06:01

MAK


People also ask

How do you get the day of the week from a date in PostgreSQL?

To extract the day name from the date, you can use the to_char() function. The first parameter is the date and the second is the desired output format. To extract the full day name, the format should be 'Day' : SELECT to_char( date '2022-01-01' , 'Day' );

How do I get the first day of a week in Postgres?

Use the DATE_PART() function to retrieve the week number from a date in a PostgreSQL database. This function takes two arguments. The first argument is the date part to retrieve; we use 'week', which returns the week number (e.g. “1” for the first week in January, the first week of the year).

Does Postgres have Sysdate?

One of the most common issues while migrating from Oracle to Amazon RDS or Amazon Aurora PostgreSQL is with the SYSDATE function. SYSDATE is the most commonly used date/time function in applications or stored procedures and triggers.

What is Dow in PostgreSQL?

Returns a numeric value (1 to 7) representing the day of the week for a specified date or datetime.


1 Answers

Try to_char():

select to_char(now(), 'Day')
like image 114
Andomar Avatar answered Oct 03 '22 06:10

Andomar