Diagnostic Queries
Symptoms
A string given where a time was expected does not parse as a valid time of day. PostgreSQL raises SQLSTATE 22007 (invalid_datetime_format).
- Malformed time text or out-of-range hour/minute/second.
- Common with bad separators or extra tokens.
- The message echoes the offending value.
What the server log shows
ERROR: invalid input syntax for type time: "25:61"
Why PostgreSQL raises this — what the manual says
Section 8.5.1 Date/Time Input:
“Date and time input is accepted in almost any reasonable format”
The time input function parses hours/minutes/seconds and validates their ranges. Malformed or out-of-range text cannot form a valid time and is rejected with 22007.
Common causes
- Hour > 24 or minute/second out of range.
- Wrong separators or extra characters.
- An empty string instead of NULL.
How to fix it
- Use a valid
HH:MM:SSformat. - Validate/normalize time strings in the application.
- Use NULL for missing values.
Related & next steps
Reference: PostgreSQL 18 Section 8.5 “Date/Time Types”.
Thanks — noted. This helps keep the database accurate.