Invalid Input Syntax
Error message
invalid input syntax for type
Quick summary
The value you provided cannot be converted to the column's data type — e.g., 'abc' for an integer, or '2023-13-45' for a date.
Why this happens
Providing a non-numeric string for a numeric column
Providing a malformed date or timestamp
Providing an invalid UUID, JSON, or boolean value
Application sends string values instead of properly typed values
Minimal example
INSERT INTO events (id, event_date) VALUES (1, '2023-13-45');
-- Invalid date: month 13 and day 45 don't existINSERT INTO events (id, event_date) VALUES (1, '2023-12-15');The date '2023-13-45' is invalid. Using a real date fixes the error.
How to diagnose
Read the error to see which type was expected and what value was provided
Check the column's data type
Verify the format of the value being inserted
How to fix
Provide the value in the correct format
Use explicit type conversion:
CAST('123' AS INTEGER)Validate and format the value in the application before inserting
Use parameterized queries with correct types
How to prevent
Use parameterized queries — the driver handles type conversion
Validate input format in the application (e.g., date parsing)
Use an ORM that maps types correctly