Get day of week from Timestamp in Postgresql

In order to Get day of week from Timestamp in postgresql we use Extract Keyword. Within the Extract keyword we have to mention DOW as we are getting day of week from timestamp

Let’s see how to

  • Extract get day of week from Timestamp in Postgresql
  • Create the column which extracts day of week from timestamp column

With an example for both

 

Extract day of week from Timestamp in Postgresql:

Within the Extract keyword we have to mention DOW as we are getting day of week from timestamp

SELECT EXTRACT (DOW FROM TIMESTAMP '2011-11-22 13:30:15')

So the resultant day of week will be

Extract Day of the week from timestamp in postgresql 2

 

EXTRACT day of week from Timestamp in column of Postgresql table:

We use table student_detail

Extract Day of the week from timestamp in postgresql 1

 

Create the column which extracts DOW from timestamp column in Postgresql

We have created a column and stored Day of week from Birthdaytime column

SELECT *,EXTRACT (DOW FROM Birthdaytime) AS DOW FROM Student_detail

So the resultant table will be

Extract Day of the week from timestamp in postgresql 3