DBAtlas · Database operations atlas

22007: invalid_datetime_format

PostgreSQL

What does it mean?

A text value was not in a valid format when converted to a date/time type (date, time, timestamp). The value does not match the expected date-time format.

Why does it happen?

Date text in an unexpected format (day/month/year order confusion); invalid day/hour values; converting an empty string ('') to a date; missing or extra components; locale/format mismatch; a wrong format mask for to_timestamp/to_date.

How to fix it

Convert the date text with the correct format: to_date('2026-07-04', 'YYYY-MM-DD') or to_timestamp(str, 'YYYY-MM-DD HH24:MI:SS'). Prefer the ISO 8601 format (YYYY-MM-DD). Turn empty values into NULL with NULLIF(value,''). Validate input data before loading; narrow down the bad row.

Open in DBAtlas →

More from this engine