MySQL & MariaDB error 1292: Incorrect date / datetime value (truncated incorrect value)
Incorrect date value: '01/23/08' for column 'sdate' at row 1 (5.7.44) A value can't be converted to a valid DATE, DATETIME or TIMESTAMP, or a string-to-number conversion lost data. In strict mode inserts fail; elsewhere it is a warning.
| MySQL | MariaDB | |
|---|---|---|
| Symbol | ER_TRUNCATED_WRONG_VALUE | ER_TRUNCATED_WRONG_VALUE |
| SQLSTATE | 22007 | 22007 |
| Type | Server error | Server error |
| Versions | every release since 5.0 active | every release since 5.5 active |
What it means
Incorrect date value: '2024-02-30' for column 'd' at row 1. MySQL and MariaDB only accept dates they can parse as YYYY-MM-DD (or a few compatible forms) that exist on the calendar. In SELECT expressions the same problem appears as a warning: Truncated incorrect DOUBLE value: 'abc'.
Why it happens
- Impossible dates (February 30th) or other formats such as
25/12/2024or12-25-2024. - The zero date
0000-00-00or zero parts (2024-00-10): rejected byNO_ZERO_DATE/NO_ZERO_IN_DATE, which are part of strict mode on MySQL 5.7+. MariaDB’s defaultsql_modedoesn’t include them, so zero dates are still accepted there (our tests confirm). - Upgrading from MySQL 5.6 (non-strict by default), where bad dates were stored as
0000-00-00with a warning. TIMESTAMPvalues outside 1970–2038.- Comparing a string column to a number (
WHERE varchar_col = 0) produces 1292 warnings for every non-numeric row.
How to fix it
- Convert other formats explicitly:
STR_TO_DATE('25/12/2024', '%d/%m/%Y'). - Use
NULLfor unknown dates instead of0000-00-00, and make the column nullable. - Clean existing zero dates before upgrading:
UPDATE t SET d = NULL WHERE d = '0000-00-00';(run it with a relaxed sessionsql_modeif the server refuses to read them). - Compare strings with strings:
WHERE varchar_col = '0'.
Reproduce it yourself
These steps are the exact test our harness runs. Use a scratch server, never production.
Connect with
mysql -u root -pand create a scratch database and the test data:CREATE DATABASE demo; USE demo; CREATE TABLE ev (d DATE);Run:
INSERT INTO ev VALUES ('2024-02-30');
You get: Incorrect date value: '2024-02-30' for column `t_0`.`ev`.`d` at row 1(11.8.9)
Verified fixes
Parse non-ISO input with STR_TO_DATE
INSERT INTO ev VALUES (STR_TO_DATE('25/12/2024', '%d/%m/%Y')); SELECT CAST(d AS CHAR) FROM ev;
Tested on
| Step | MySQL | MariaDB | |||||||
|---|---|---|---|---|---|---|---|---|---|
| 5.6 | 5.7 | 8.0 | 8.4 | 9 | 10.6 | 10.11 | 11.4 | 11.8 | |
| Insert an impossible date (strict mode) repro | ≠ | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 |
| A date in day/month/year format version check | ≠ | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 |
| The zero date '0000-00-00' (NO_ZERO_DATE in strict mode) version check | ≠ | ✓ 1292 | ✓ 1292 | ✓ 1292 | ✓ 1292 | ≠ | ≠ | ≠ | ≠ |
| Parse non-ISO input with STR_TO_DATE fix | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
What the warnings and failures say (3)
- Insert an impossible date (strict mode) (MySQL 5.6): expected error 1292 did not occur
- A date in day/month/year format (MySQL 5.6): expected error 1292 did not occur
- The zero date '0000-00-00' (NO_ZERO_DATE in strict mode) (MySQL 5.6, MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): expected error 1292 did not occur
Related errors
Where this error shows up in our guides
- LOAD DATA INFILE variable data · Date in the wrong format without SET conversion MySQL 5.7 8.0 8.4 9MariaDB 10.6 10.11 11.4 11.8
- TIMEDIFF · TIMEDIFF over ~35 days is capped at 838:59:59 (TIME range) MySQL 5.6 5.7 8.0 8.4 9MariaDB 10.6 10.11 11.4 11.8
How the message changed between versions
| MariaDB from | Symbol | Message |
|---|---|---|
| 5.5.68 | ER_TRUNCATED_WRONG_VALUE | Truncated incorrect %-.32s value: '%-.128s' |
| 10.2.44 | ER_TRUNCATED_WRONG_VALUE | Truncated incorrect %-.32T value: '%-.128T' |
| 11.8.10 | ER_TRUNCATED_WRONG_VALUE | Truncated incorrect %-.32sT value: '%-.128sT' |