Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a default date format on PostgreSQL

Tags:

sql

postgresql

Good afternoon,

Many of you may already know that it is possible, for instance, in Oracle set the default date format used by formatting functions (ie to_char), just like this:

ALTER SESSION SET NLS_DATE_FORMAT='SYYYY/MM/DD~HH24:Mi:SS'

My question is: is there any equivalence for this on PostgreSQL. I have been searching for an answer without success although I have found some references to the PostgreSQL locale settings (http://www.postgresql.org/docs/7.4/static/charset.html). Anyhow, I have been unable to figure out an answer.

Any suggestions? Thank you in advance and best wishes for this holidays!

like image 802
Sergio Avatar asked Sep 03 '26 13:09

Sergio


1 Answers

It's possibly that SET DATESTYLE does what you want, at least for day, month, year portions of the date.

Search here for DateStyle.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!