scribase
SQLSTATE 22007invalid_datetime_formatHTTP 400

Postgres error 22007: invalid datetime format

invalid input syntax for type timestamp / date

Text could not be parsed as a date or time.

Common causes

  • Ambiguous or locale-specific formats such as 08/10/2026 when DateStyle expects a different order.
  • Empty strings sent for a timestamp column instead of null.

How to fix it

  • Send ISO 8601 (2026-10-08T14:30:00Z) from the app.
  • Convert empty strings to null before writing.
  • Use to_timestamp(text, format) when you must parse a fixed custom format.

Through a REST API

PostgREST, the REST layer behind supabase-js and Scribase, answers HTTP 400 for this error and returns the SQLSTATE in the code field of the JSON error body.

Questions

What does Postgres error 22007 mean?

22007 is invalid_datetime_format in class 22 (Data Exception). Text could not be parsed as a date or time.

How do I fix 22007?

Send ISO 8601 (2026-10-08T14:30:00Z) from the app. Convert empty strings to null before writing. Use to_timestamp(text, format) when you must parse a fixed custom format.

What HTTP status does a REST API return for 22007?

PostgREST, the REST layer behind supabase-js, answers 400.

Other class 22 errors

  • 22001 value too long for type character varying(n)
  • 22003 integer out of range / numeric field overflow
  • 22008 date/time field value out of range
  • 22012 division by zero
  • 22P02 invalid input syntax for type uuid / integer