select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / CLIENT CONNECTION DEFAULTS

Sets the display format for date and time values, as well as the rules for interpreting ambiguous date input values.

Type
string
Context
user
Measured default
ISO, MDY
Unit
Metadata snapshot
18

Definition PG 18 manual

Sets the display format for date and time values, as well as the rules for interpreting ambiguous date input values. For historical reasons, this variable contains two independent components: the output format specification (ISO, Postgres, SQL, or German) and the input/output specification for year/month/day ordering (DMY, MDY, or YMD). These can be set separately or together. The keywords Euro and European are synonyms for DMY; the keywords US, NonEuro, and NonEuropean are synonyms for MDY. See Section 8.5 for more information. The built-in default is ISO, MDY, but initdb will initialize the configuration file with a setting that corresponds to the behavior of the chosen lc_time locale.

Measured default history
Version intervalDefault
9.0 – 19ISO, MDY
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

DateStyle sets the display format for date and time values. Also controls interpretation of ambiguous date inputs. The value has two independent parts: an output style and a DMY/MDY/YMD field order; the latter also resolves ambiguous input.

DateStyle is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.

It changes representation, parsing, or locale behavior at the client boundary rather than physical storage. Coordinate it with the other locale and formatting settings and with driver-native binary or typed protocols.

Operational considerations

Changing DateStyle in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.

Assuming a presentation setting changes stored values or server-side type semantics.

Changing a role or database default without testing text-parsing clients, exports, and pooled sessions.

Parsing an ambiguous value such as 01/02/03 under an unexpected MDY/DMY order.

Workload guidance

OLAP: Pin DateStyle for export, reporting, and reproducible analytical jobs; prefer explicit SQL formatting when a file or API has a durable schema.

OLTP: Treat DateStyle as an application contract, not a performance knob. Standardize it per role or connection pool and keep wire formats explicit where clients parse text.

SMALL: Keep the upstream or locale-derived value unless a client requires another one. A smaller server gains no capacity from changing DateStyle.

Related entries

Further reading

Definition snapshot: english-manuals:7db8534c6f6db0b32221635333a… · English manual source