scribase
SQLSTATE 22008datetime_field_overflowHTTP 400

Postgres error 22008: datetime field overflow

date/time field value out of range

The text parsed but the value is impossible, such as month 13 or 30 February, or day and month were swapped.

Common causes

  • A day-first date read with a month-first DateStyle (13/02/2026).
  • Invalid dates generated by string concatenation.

How to fix it

  • Use ISO 8601 dates.
  • Build dates with make_date(year, month, day) or make_timestamptz instead of strings.

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 22008 mean?

22008 is datetime_field_overflow in class 22 (Data Exception). The text parsed but the value is impossible, such as month 13 or 30 February, or day and month were swapped.

How do I fix 22008?

Use ISO 8601 dates. Build dates with make_date(year, month, day) or make_timestamptz instead of strings.

What HTTP status does a REST API return for 22008?

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
  • 22007 invalid input syntax for type timestamp / date
  • 22012 division by zero
  • 22P02 invalid input syntax for type uuid / integer