This is a misunderstanding.
If your data type is date
, then it is stored without format. It's just a 4-byte integer counting seconds since 2000.
You can format it any way when displaying to the client.
SELECT to_char(mydate, 'yyyy-mm-dd') AS one_way
,to_char(mydate, 'dd/mm/yyyy') AS other_way
'yyyy-mm-dd'
happens to be ISO 8601 format, which is the default text representation in many locales.
You can always create a VIEW
with a text representation of the date:
CREATE VIEW v_tbl_with_date_foramt AS
SELECT id, some_column, to_char(mydate, 'dd/mm/yyyy') AS mydate_text
FROM tbl;
But now it's a text
column, not a date
column.
datestyle
is responsible for how input date literals are interpreted.
LC_TIME
regulates how date/time functions behave.
The default display is the ISO 8601: 'yyyy-mm-dd'
.