PostgreSQL: invalid input syntax for type timestamp
ERROR: invalid input syntax for type timestamp: "<value>"A value sent to a timestamp or date column is not a recognizable date or time, often an ambiguous format, an empty string, or a Unix epoch integer. Use ISO 8601, or parse with to_timestamp.
What this error means
Postgres parses timestamp text according to its DateStyle setting. When the text does not match a recognizable format, it raises this error and quotes the value.
Ambiguous formats, empty strings, and epoch integers sent as strings are the usual causes.
How to fix it
The format is ambiguous or non-standard
Use ISO 8601, which is unambiguous.
INSERT INTO t (at) VALUES ('2026-07-31T12:00:00Z');You have a custom format
Parse it explicitly with to_timestamp and a format string.
SELECT to_timestamp('31-07-2026', 'DD-MM-YYYY');An empty string reaches the column
Convert an empty string to NULL before insert.
INSERT INTO t (at) VALUES (NULLIF($1, '')::timestamptz);How to avoid it next time
- Standardize on ISO 8601 and store timestamptz.
- Normalize empty date fields to null at the application boundary.
Frequently asked questions
Why is my date parsed as the wrong month?
Ambiguous formats like MM/DD versus DD/MM depend on DateStyle. Use ISO 8601 (YYYY-MM-DD) to remove the ambiguity.
Should I use timestamp or timestamptz?
Prefer timestamptz, which stores an absolute point in time. Plain timestamp ignores time zones and is a common source of bugs.
Stop struggling with SQL
Use FluentDB, the AI database client for macOS.
Related errors
Part of the PostgreSQL error reference. Last reviewed 2026-07-31.