Seaquel
PostgreSQL error code

PostgreSQL error 22007

22007 is the SQLSTATE PostgreSQL reports for invalid datetime format, in class 22, Data Exception.

SQLSTATE22007
Condition nameinvalid_datetime_format
Class22 — Data Exception

Reproduce it, then fix it

PostgreSQL parses dates and a few special words like today and yesterday, but not phrases like last week. Relative dates come from arithmetic on now(). 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 > 'last week';
SELECT id, created_at
FROM orders
WHERE created_at > now() - interval '1 week';

Source: PostgreSQL documentation, Appendix A