How to Fix MySQL Error 1299 (ER_WARN_INVALID_TIMESTAMP)
You see mysql error 1299 when a query tries to write a bad timestamp value. You fix it by sending valid UTC times or updating the column data type. In the database engine, this failure carries the official symbol ER_WARN_INVALID_TIMESTAMP and SQLSTATE HY000. The server reports an invalid TIMESTAMP value in a specific column and row. When strict SQL rules run, the engine rejects the write and stops the query. Teams often hit this wall during spring daylight saving shifts or bulk data imports.
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You see mysql error 1299 when a query tries to write a bad timestamp value. You fix it by sending valid UTC times or updating the column data type.
In the database engine, this failure carries the official symbol ER_WARN_INVALID_TIMESTAMP and SQLSTATE HY000. The server reports an invalid TIMESTAMP value in a specific column and row. When strict SQL rules run, the engine rejects the write and stops the query. Teams often hit this wall during spring daylight saving shifts or bulk data imports.
What causes mysql error 1299 in your database
The MySQL TIMESTAMP type stores values in a strict UTC range. It starts in early 1970 and ends in early 2038. Any date outside this narrow window triggers the ER_WARN_INVALID_TIMESTAMP message right away. Historical birth dates or far future expiration dates will fail in this column type.
Time zone shifts also cause this specific failure in production apps. When clocks jump forward for daylight saving time, one local hour disappears. If your client session uses a local time zone, that missing hour is invalid. The database rejects any timestamp that falls inside that skipped one-hour gap.
Zero dates and malformed strings also set off this error. Old backups often hold all-zero date strings as empty placeholders. Modern database rules treat zero dates and impossible leap days as bad values. When a migration script reads those old rows, the write step fails.
How to find the bad row and column
Start your check by reading the full error message from the server log. The message names the exact column and the row number that caused the failure. This detail tells your team where to look in the incoming data payload.
Next, check the time zone settings on both the server and the app client. When an app sends local timestamps, daylight saving gaps will break your writes. You should also inspect the raw input file if you run a batch import. Look for empty strings, zero dates, or years past 2038 in the target row.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
During this check, your engineers might query tables that hold user records. Good access tools rewrite matched fields like emails and phone numbers in query results. This lets the team find bad timestamps while keeping sensitive user details safe.
How to fix and prevent invalid timestamp errors
Do not turn off strict SQL rules to bypass this error in production. Dropping strict checks forces the database to turn bad dates into zero values. That silent change corrupts your records and breaks your reports later.
The best fix is to set every app and database session to UTC. UTC never shifts for daylight saving time and never skips an hour. Convert local user times to UTC in the app before you send the write.
If you must store dates before 1970 or after 2038, change the column type. Alter the table to use the DATETIME type instead of the TIMESTAMP type. DATETIME supports a huge year range and ignores time zone shifts during storage. For empty values, make the column nullable and send a clean null value.
Add wire guardrails and masking beside MySQL
Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.
With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.
Frequently asked questions
Why does mysql error 1299 happen during daylight saving time changes?
When local clocks spring forward, one hour of local time does not exist. If your session uses that local time zone, timestamps in that gap are invalid. Setting your database session to UTC stops this issue for good.
Should I change my column from TIMESTAMP to DATETIME to fix error 1299?
Yes, use DATETIME if you store dates before 1970 or after early 2038. TIMESTAMP only fits a small window of years and fails outside that range. DATETIME holds a much wider range of years without time zone conversion.
Is it safe to disable strict mode to stop ER_WARN_INVALID_TIMESTAMP?
No, turning off strict rules lets the server write broken zero dates into tables. Fix the bad input data in your app or allow null values instead. This keeps your production data clean and accurate over time.
Related guides
In this post