SQLSTATE 22015 ERROR Class 22: Data Exception

interval_field_overflow interval out of range — 22015

PostgreSQL error "interval out of range" (SQLSTATE 22015): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

An interval computation or value exceeded the representable range. PostgreSQL raises SQLSTATE 22015 (interval_field_overflow).

  • Interval arithmetic overflowed the type’s range.
  • Common with multiplying intervals by large factors.
  • Also seen adding many large intervals.

What the server log shows

ERROR:  interval out of range

Why PostgreSQL raises this — what the manual says

Section 8.5.4 Interval Input:

“Internally, interval values are stored as three integral fields: months, days, and microseconds.”

Intervals store months/days/microseconds within fixed limits. A computation producing a value beyond those limits cannot be represented and PostgreSQL reports 22015.

Common causes

  • Multiplying an interval by a very large number.
  • Summing many large intervals.
  • Constructing an interval with extreme field values.

How to fix it

  1. Keep interval magnitudes within the supported range.
  2. Recompute using smaller units or split the calculation.
  3. Validate factors before scaling intervals.

Related & next steps

Reference: PostgreSQL 18 Section 8.5 “Date/Time Types”.

Was this helpful?