// PostgreSQL error reference

PostgreSQL 22008: date/time field value out of range

A date or time had a field outside its valid range, such as month 13 or day 31 in a 30-day month, or a day/month order mix-up.

SQLSTATE
22008
Name
datetime_field_overflow
Category
Data Exception
Error message
date/time field value out of range: "2026-13-01"

What it means

The input looked like a date or time, but one of its fields is impossible: a month above 12, a day that doesn't exist in that month, an hour above 24. 22008 (datetime_field_overflow) also covers results outside the representable range, such as timestamp out of range.

When the value is a numeric date like 13/01/2026, PostgreSQL adds a hint that you may need a different DateStyle, because it read 13 as the month.

Common causes

  • Day and month swapped relative to the session's DateStyle.
  • Invalid calendar dates in source data, such as February 30.
  • Date arithmetic that produces a value beyond the supported range.

How to fix it

  1. Use ISO 8601 dates (YYYY-MM-DD), which are never ambiguous.

  2. If the data is day-first, say so, or parse it with an explicit format.

    SET DateStyle = 'ISO, DMY';
    SELECT '13/01/2026'::date;
    -- or
    SELECT to_date('13/01/2026', 'DD/MM/YYYY');
  3. Find bad rows in a staging table before converting them (PostgreSQL 16 and later).

    SELECT raw_date FROM staging WHERE NOT pg_input_is_valid(raw_date, 'date');

Reproduce it safely

SELECT '2026-02-30'::date;  -- ERROR: date/time field value out of range: "2026-02-30"

Related errors

More data exception errors

The code and message text are from the PostgreSQL documentation, Appendix A: PostgreSQL Error Codes. Browse the full PostgreSQL error list or search every database error.

// fewer errors, faster fixes

Work on PostgreSQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for PostgreSQL and the other databases you use.