PostgreSQL error code
PostgreSQL error 22008
22008 is the SQLSTATE PostgreSQL reports for datetime field overflow, in class 22, Data Exception.
| SQLSTATE | 22008 |
|---|---|
| Condition name | datetime_field_overflow |
| Class | 22 — Data Exception |
Reproduce it, then fix it
February 2024 has 29 days. PostgreSQL rejects an impossible date instead of rolling it over into March, so compare against the first day of the next month. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT id, created_at FROM orders WHERE created_at < '2024-02-30';
SELECT id, created_at FROM orders WHERE created_at < '2024-03-01';