PostgreSQLERROR 22007
PostgreSQL: Invalid Datetime Format
PostgreSQL 22007 is raised when a string cannot be interpreted as a valid date or timestamp in the expected format. PostgreSQL expects ISO 8601 format by default.
Example Query
INSERT INTO events (created_at) VALUES ('21/03/2024 10:00');
-- DD/MM/YYYY is not the default formatCommon Causes
- 1Date string in non-ISO format (DD/MM/YYYY, MM-DD-YYYY)
- 2Timestamp with unsupported timezone abbreviation
- 3DateStyle setting mismatch between client and server
How to Fix It
Use ISO 8601 format: '2024-03-21 10:00:00'. Use TO_TIMESTAMP to parse non-standard formats: TO_TIMESTAMP('21/03/2024', 'DD/MM/YYYY'). Set DateStyle in postgresql.conf or per session: SET datestyle = 'ISO, DMY'.
Need a reliable database?
Try Supabase — free PostgreSQL with a generous free tier. No credit card required.
Got a query causing this error?
Paste it into SQLbuddy and get an instant plain-English explanation with optimization tips.
Analyze My Query →