SQLSTATE 22008Severity lowLab verified

Incident brief

Datetime field overflow

A date/time value was well-formed text, but named a value that doesn't exist on the calendar or falls outside PostgreSQL's supported range.

What lands in your log

ERROR: date/time field value out of range: "2024-02-30"

Reproduced on PostgreSQL 16.14Verified 2026-07-16 (Docker lab, PostgreSQL 16.14)Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What triggers it
Cast a well-formed date string that names an impossible calendar day, such as February 30th.
Fix
Validate day-of-month against the actual month and leap-year rules before sending it to PostgreSQL, or just let PostgreSQL reject it and handle the error.
Proof
Reproduced on PostgreSQL 16.14 → Casting a well-formed but nonexistent calendar date (February 30th) was rejected with SQLSTATE 22008. The session was unaffected afterward.

Fix

What to do right now

Application-level steps for this error.

  • Validate day-of-month against the actual month and leap-year rules before sending it to PostgreSQL, or just let PostgreSQL reject it and handle the error.
  • Don't assume a regex/format check is enough, see the premium test for a second, unrelated way this same SQLSTATE is triggered.
  • For application-computed dates (e.g. 'add N months'), check the result is still inside PostgreSQL's supported date range (4713 BC to 5874897 AD).
Fix SQL
SELECT '2024-02-29'::date; -- 2024 is a leap year

Connected

Everything this error touches

Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.

Open in the interactive map →

Verification

PG 16.14
Last verified
2026-07-16 (Docker lab, PostgreSQL 16.14)
Verification scope
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed
ShareLinkedInX

Went further?

Pro unlocks the second lab proof

Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.

FollowSubstackLinkedInnew errors · lab notes · hiring loops