SQLSTATE 22007Severity lowLab verified

Incident brief

Invalid datetime format

A text value was cast to a date/time type, but PostgreSQL couldn't parse it as any recognized date/time format at all.

What lands in your log

ERROR: invalid input syntax for type date: "not-a-real-date"

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 plain, unparseable text to date.
Fix
Send dates in ISO 8601 format (YYYY-MM-DD), the manual's own recommended, unambiguous format.
Proof
Reproduced on PostgreSQL 16.14 → Casting plain garbage text to date was rejected with SQLSTATE 22007. The session was unaffected afterward.

Fix

What to do right now

Application-level steps for this error.

  • Send dates in ISO 8601 format (YYYY-MM-DD), the manual's own recommended, unambiguous format.
  • Validate the string is even shaped like a date in application code before sending it to PostgreSQL.
  • Don't confuse this with 22008, see the premium test for the difference between 'unreadable' and 'reads fine but doesn't exist'.
Fix SQL
SELECT '1999-01-08'::date;

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