MySQL → PostgreSQL
Convert MySQL DATETIME to PostgreSQL timestamp
MySQL DATETIME stores a wall-clock value with no time zone. The matching PostgreSQL type is timestamp (without time zone); zero dates need special care.
DATETIME → timestamp
What to know
- DATETIME → timestamp; the values transfer unchanged
- MySQL's '0000-00-00 00:00:00' is invalid in PostgreSQL and becomes NULL
- DATETIME(6) microsecond precision is preserved (timestamp keeps 6 digits)
- If your values are actually UTC instants, consider timestamptz after import
Before / after
MySQL
CREATE TABLE orders (
placed_at DATETIME(6) NOT NULL
); PostgreSQL
CREATE TABLE orders (
placed_at timestamp(6) NOT NULL
); Don't convert column-by-column — convert the whole database.
Upload a dump, get back ready-to-import SQL with this mapping (and every other one) applied.
Open the MySQL → PostgreSQL converterSee the full type mapping table or all guides.