How can you select short day name in Postgres, e.g. "Mon", "Tue", "Wed"?
Not the full day name "Monday", "Tuesday", "Wednesday".
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With