The SET DATESTYLE command changes the DATESTYLE run-time parameter for the current session.
Syntax
SET DATESTYLE TO { value | 'value' } [ ,... ]
Semantics
The DATESTYLE parameter can have multiple, non-conflicting values:
Value |
Interpretation |
Example |
MDY |
month-day-year |
12/17/1997 |
DMY |
day-month-year |
17/12/1997 |
YMD |
year-month-day |
1997-12-17 |
ISO |
ISO 8601/SQL standard (default) |
1997-12-17 07:37:16-08 |
SQL |
traditional style |
12/17/1997 07:37:16.00 PST |
POSTGRES |
original style |
Wed Dec 17 07:37:16 1997 PST |
GERMAN |
regional style |
17.12.1997 07:37:16.00 PST |
In the SQL and POSTGRES styles, day appears before month if DMY field ordering has been specified, otherwise month appears before day. (See Date/Time Constants for how this setting also affects interpretation of input values.) The table below shows an example.
DATESTYLE |
Input Ordering |
Example Output |
|
day/month/year |
17/12/1997 15:37:16.00 CET |
|
month/day/year |
12/17/1997 07:37:16.00 PST |
|
day/month/year |
Wed 17 Dec 07:37:16 1997 PST |
Notes
INTERVAL
output looks like the input format, except that units like CENTURY
or WEEK
are converted to years and days and AGO
is converted to an appropriate sign. In ISO mode the output looks like[ quantity unit [ ... ] ] [ days ] [ hours:minutes:seconds ]
Example
SET DATESTYLE TO POSTGRES, MDY;