MySQL ERROR 1292: Incorrect datetime value means MySQL was handed a string it would not accept as a DATE, DATETIME or TIMESTAMP, and strict SQL mode turned that into a hard error instead of a warning.
mysql> INSERT INTO orders (created_at) VALUES ('0000-00-00 00:00:00');
ERROR 1292 (22007): Incorrect datetime value: '0000-00-00 00:00:00' for column 'created_at' at row 1
mysql> INSERT INTO orders (ship_date) VALUES ('2026-02-30');
ERROR 1292 (22007): Incorrect date value: '2026-02-30' for column 'ship_date' at row 1
The server error reference lists code 1292 as ER_TRUNCATED_WRONG_VALUE, SQLSTATE 22007 (invalid datetime format). Its generic text is "Truncated incorrect %s value", but when the bad value is headed for a column you see the more useful form above, with the column name and the row number. In a WHERE clause the same bad literal can surface as ERROR 1525 Incorrect DATETIME value instead. Either way the cause is in the value, not the table, so the first job is to see exactly what string arrived.
The four usual causes
In our experience almost every 1292 comes from one of these.
- Zero dates.
'0000-00-00'and'0000-00-00 00:00:00'are rejected because the default SQL mode in MySQL 8.4 includesSTRICT_TRANS_TABLES,NO_ZERO_DATEandNO_ZERO_IN_DATE. Dates like'2026-11-00'(a zero day or month) fall underNO_ZERO_IN_DATE. Old applications written for MySQL 5.x often used zero dates to mean "not set". - Dates that do not exist.
'2026-02-30'or'2026-04-31'fail because MySQL checks the calendar, not only that the month is 1 to 12 and the day 1 to 31. - Foreign formats. MySQL reads
'YYYY-MM-DD hh:mm:ss'. Strings such as'29/11/2026', HTTP dates or an empty string''from a web form are not dates to it. - Out of range for the type.
TIMESTAMPcovers only'1970-01-01 00:00:01'to'2038-01-19 03:14:07'UTC, so a birth date in 1965 or a contract end in 2040 fails there.DATETIMEcovers years 1000 to 9999.
ISO 8601 strings and time zones
A common modern variant comes from JavaScript and JSON APIs. new Date().toISOString() produces '2026-11-29T10:00:00.000Z', and MySQL rejects it. The T separator is fine, as the date and time literals page says, and so are fractional seconds. The problem is the trailing Z.
MySQL does accept a numeric offset appended to the time, such as '2026-11-29 10:00:00+02:00'. The offset uses the same format as the time_zone variable, the hour needs a leading zero, '-00:00' is rejected and named zones like 'Europe/Riga' are not allowed. The value is converted to the session time zone on insert, so the offset itself is not stored.
-- rejected: not a MySQL datetime literal
'2026-11-29T10:00:00Z' -- JavaScript toISOString(), trailing Z
'29/11/2026 10:00' -- day/month/year
'Sun, 29 Nov 2026 10:00:00 GMT' -- HTTP date
'' -- empty string from a form or CSV
-- accepted
'2026-11-29 10:00:00'
'2026-11-29T10:00:00' -- T instead of a space is fine
'2026-11-29 10:00:00+02:00' -- numeric offset, converted on insert
-- parse foreign formats explicitly
INSERT INTO orders (created_at)
VALUES (STR_TO_DATE('29/11/2026 10:00', '%d/%m/%Y %H:%i'));
The cleanest fix is to send a plain 'YYYY-MM-DD hh:mm:ss' value from the application, or let the driver bind a native date object. Decide once whether the database stores UTC, and set the session time_zone accordingly. For TIMESTAMP columns MySQL converts from the session time zone to UTC for storage and back on read, as the DATETIME documentation explains. DATETIME stores exactly what it is given.
How to fix it
- Log the exact value the application sent. The error message quotes it, which is often enough.
- Check the SQL mode of the failing session, not only of the server. Connection pools, ORMs and migration tools sometimes set their own
sql_mode. - Fix the value at the source: send
NULLfor "unknown" (and make the column nullable), validate dates in the application, and parse non-standard formats withSTR_TO_DATE(). Per the function reference,STR_TO_DATE()returnsNULLwith a warning when the string cannot be parsed, so pair it with aNOT NULLcolumn or a check if you need a hard failure. - Use a
DATETIMEinstead of aTIMESTAMPfor values outside 1970 to 2038.
-- what is this session enforcing?
SELECT @@SESSION.sql_mode;
-- rows with zero dates or zero month/day parts
SELECT id, CAST(created_at AS CHAR) AS raw_value
FROM orders
WHERE MONTH(created_at) = 0 OR DAY(created_at) = 0
LIMIT 100;
Do not "fix" it by removing modes. Dropping NO_ZERO_DATE or strict mode makes the error go away, but the SQL mode documentation is clear about what happens next: without strict mode invalid dates are stored as '0000-00-00' with only a warning, and garbage strings are truncated. ALLOW_INVALID_DATES lets '2026-02-30' into DATE and DATETIME columns as is. Both NO_ZERO_DATE and NO_ZERO_IN_DATE are deprecated, and MySQL says their effect is expected to become part of strict mode, so relying on turning them off is a short-term bet. The related truncation case is covered in our article on ERROR 1265 Data truncated for column.
CSV imports with LOAD DATA
Bulk loads hit 1292 on empty fields and local date formats. In strict mode one bad line stops the whole LOAD DATA, and on InnoDB nothing from that statement is kept. The LOAD DATA documentation lets you read a field into a user variable and transform it in the SET clause, which handles both problems in one pass:
LOAD DATA INFILE '/var/lib/mysql-files/orders.csv'
INTO TABLE orders
FIELDS TERMINATED BY ','
(id, @created)
SET created_at = CASE
WHEN @created = '' THEN NULL
WHEN @created LIKE '__.__.____' THEN STR_TO_DATE(@created, '%d.%m.%Y')
ELSE @created
END;
Avoid the shortcut of LOAD DATA ... IGNORE for dates. It turns the errors into warnings, and rows you cannot parse quietly get a zero date or NULL, which is usually worse than a failed import.
Legacy zero dates on large tables
The hardest 1292 cases appear on big, old tables after an upgrade or a move to a new server with the default SQL mode. The data loaded fine and reads fine, but now ordinary work fails:
- A dump restores, then the trouble starts.
mysqldumpwritesSET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'at the top of the file, so zero dates are restored without complaint. The errors only appear later, when the application writes them back or a schema change touches them. - Table-copy ALTERs re-check every row. An
ALTER TABLEthat copies rows (ALGORITHM=COPY, typically a column type change) stops with 1292 at the first zero date it meets, which can be hours into a rebuild of a large table. In our experience in-place operations usually do not re-validate existing values, so the same table can pass one ALTER and fail the next. Any tool that copies rows into a new table should be treated the same way. - Zero defaults block schema changes. A column declared
DEFAULT '0000-00-00 00:00:00'makes even an unrelatedALTERor aCREATE TABLE ... LIKEfail in strict mode with ERROR 1067Invalid default value. Change the default before anything else. - Finding the rows is a full scan.
MONTH(col) = 0cannot use an index, so run the search on a replica or in key ranges, not as one statement on the primary at peak time.
The safe order on a large table is: change the default and nullability of the column, update the application so it stops writing zero dates, clean existing rows in primary key batches while watching replica lag, confirm the count is zero, and only then run the type change or the upgrade. Batch size depends on row width and load; in our experience a few thousand to tens of thousands of rows per statement keeps locks short.
-- 1. make the column nullable first if zero dates meant "unknown"
-- (or pick a real sentinel value your application understands)
-- 2. fix legacy rows in primary-key ranges, not in one statement
UPDATE orders
SET created_at = NULL
WHERE id BETWEEN 1 AND 50000
AND (MONTH(created_at) = 0 OR DAY(created_at) = 0);
-- 3. repeat for the next range, check replica lag between batches,
-- then confirm nothing is left before the schema change
SELECT COUNT(*) FROM orders
WHERE MONTH(created_at) = 0 OR DAY(created_at) = 0;
Zero dates are one of the items we check on every major upgrade; the rest of the list is in our guide to upgrading MySQL 8.0 to 8.4.
Key takeaways
- ERROR 1292 (22007) means MySQL would not accept a string as a date or time value. The message quotes the value and the column.
- Usual causes: zero dates under
NO_ZERO_DATE, impossible calendar dates, non-MySQL formats such as a trailingZ, and the 1970 to 2038TIMESTAMPrange. - Send
'YYYY-MM-DD hh:mm:ss'or a numeric offset, useNULLfor unknown dates, and parse other formats withSTR_TO_DATE(). - Relaxing
sql_modehides the problem and stores zero dates instead. - On large legacy tables, fix zero defaults first and clean rows in batches before any table-copy
ALTERor upgrade.