Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get short day name in Postgres, e.g. "Mon", "Tue", "Wed"

Tags:

postgresql

How can you select short day name in Postgres, e.g. "Mon", "Tue", "Wed"?

Not the full day name "Monday", "Tuesday", "Wednesday".

like image 583
Random5000 Avatar asked May 13 '18 20:05

Random5000


People also ask

How do I extract the day of the week in PostgreSQL?

In PostgreSQL you can use the extract() function to get the day from a date. You can also use date_part() to do the same thing. When extracting the day from a date, you need to specify what sense of the word “day” you mean. For example, “day of week”, “day of month”, “day of year”, etc.

How do I split a date and time in PostgreSQL?

This can be done in PostgreSQL using the AGE() function. This function takes in two timestamps as arguments and then returns the interval between them.

Does Postgres have date type?

The date format for the date data type in PostgreSQL is yyyy-mm-dd . This is the format used for both storing data and for inserting data.


1 Answers

to_char(NOW(), 'Dy') or 'dy' or 'DY'

for 'Fri', 'fri', or 'FRI', respectively.

Reference: https://www.postgresql.org/docs/9.1/static/functions-formatting.html#FUNCTIONS-FORMATTING-DATETIME-TABLE

like image 143
mike.k Avatar answered Oct 20 '22 03:10

mike.k