Diagnostic Queries
Symptoms
A date/time value contains a field outside its legal range (month 13, day 32, hour 25, etc.), or the overall value is unrepresentable. PostgreSQL raises SQLSTATE 22008 (datetime_field_overflow).
- The bad value is quoted; a HINT may mention
DateStyle. - Often an ambiguous day/month order misread under the current DateStyle.
- Common in imports of mixed-format dates.
What the server log shows
ERROR: date/time field value out of range: "2026-02-30"
HINT: Perhaps you need a different "datestyle" setting.
Why PostgreSQL raises this — what the manual says
As Section 8.5.1 Date/Time Input explains:
Each date/time field must fall within its natural range (for example months 1-12, or a day number valid for the given month); a field such as month 13 or day 32 is rejected as a field value out of range.
After tokenizing the input, PostgreSQL validates each field against its legal range and the calendar. An impossible date (Feb 30) or an out-of-range field fails with 22008.
Common causes
- Impossible calendar dates (e.g. Feb 30, day 32).
- Day/month transposition under the active
DateStyle. - Out-of-range time fields.
How to fix it
- Send ISO 8601 dates to remove ambiguity.
- Set the correct
DateStyle(e.g.SET datestyle = 'ISO, DMY';). - Validate dates upstream; use
to_date()/to_timestamp()with an explicit format.
Related & next steps
Reference: PostgreSQL 18 Section 8.5 “Date/Time Types”.
Thanks — noted. This helps keep the database accurate.