PG
PRO
22015ERRORTier 2 — Caution✅ HIGH confidence

interval field overflow

Category: Data ExceptionVersions: All Postgres versions

What this means

SQLSTATE 22015 is raised when an interval value has a field that exceeds the maximum representable value, or when interval arithmetic produces a result too large to store in the interval type.

Why it happens

  1. 1Computing an interval whose microsecond, second, minute, hour, day, month, or year component overflows the internal representation
  2. 2Casting an extremely large numeric value to interval

How to reproduce

Casting an overflowing number to an interval.

trigger — this will ERROR
SELECT (1e18)::bigint * interval '1 second';
ERROR: interval field value out of range

Fix 1: Reduce the magnitude of interval inputs

When computing very large intervals.

fix

Why this works

Break the interval into smaller components or normalise the input value to fit within the interval type limits (about +/- 178,000,000 years).

Sources

📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html

🔧 Source ref: Class 22 — Data Exception

Confidence assessment

✅ HIGH confidence

Standard SQLSTATE for interval overflow. Stable across versions.

See also

📄 Reference pages

Date/Time Typesinterval
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →