MySQL 8.4Lab-verified · 2026-12-01

MySQL ERROR 1292 (22007): Incorrect date value / Incorrect datetime value

The string you are storing into a DATE or DATETIME column is not a valid date for MySQL in strict mode.

MySQL 8.4.13
1292 (22007): Incorrect date value: '30/11/2026' for column 'order_date' at row 1

Jump to a cause

  1. 01Date string in a different format (dd/mm/yyyy)
  2. 02Empty string from CSV or a form into a DATETIME column
  3. 030000-00-00 used for "no date"
  4. 04A day that does not exist, such as February 30
  5. 05Inserting a JavaScript toISOString() value ('…T10:00:00.000Z') as is

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-12-01 · container image mysql:8.4

The message shows the exact value, the column and the row number: Incorrect datetime value: '' for column 'last_login' at row 2. With INSERT … SELECT or a multi-row INSERT, the row number tells you which source row is bad.

MySQL 8.4's default sql_mode includes STRICT_TRANS_TABLES, NO_ZERO_DATE and NO_ZERO_IN_DATE, so these values are rejected instead of being stored as zero dates with a warning. The message is in English even with Korean or Japanese lc_messages.

01Date string in a different format (dd/mm/yyyy)

MySQL reads date strings as year-month-day. '30/11/2026' from Excel or a form is not understood.

Setup
Setuprun as lab_a
CREATE TABLE orders (id INT PRIMARY KEY, order_date DATE);
OUTPUT
Query OK, 0 rows affected (0.02 sec)
Reproducerun as lab_a
INSERT INTO orders VALUES (1, '30/11/2026');
✕ ERROR
ERROR 1292 (22007): Incorrect date value: '30/11/2026' for column 'order_date' at row 1
Check the causerun as lab_a
SELECT STR_TO_DATE('30/11/2026', '%Y-%m-%d') AS as_ymd, STR_TO_DATE('30/11/2026', '%d/%m/%Y') AS as_dmy;
OUTPUT
+--------+------------+
| as_ymd | as_dmy     |
+--------+------------+
| NULL   | 2026-11-30 |
+--------+------------+
1 row in set, 1 warning (0.00 sec)

Read as %Y-%m-%d, the string gives NULL; read as %d/%m/%Y, it gives 2026-11-30. The value itself is fine, only the format differs.

Convert with STR_TO_DATE('30/11/2026', '%d/%m/%Y') in the INSERT. It is stored as 2026-11-30.

Fix: run the corrected statementrun as lab_a
INSERT INTO orders VALUES (1, STR_TO_DATE('30/11/2026', '%d/%m/%Y'));
SELECT * FROM orders;
✓ SUCCESS
Query OK, 1 row affected (0.01 sec)

+----+------------+
| id | order_date |
+----+------------+
|  1 | 2026-11-30 |
+----+------------+
1 row in set (0.00 sec)

02Empty string from CSV or a form into a DATETIME column

Row 2 in the staging table has last_login = ''. An empty string is not NULL and not a date, so the whole INSERT … SELECT fails at row 2 and row 1 is not inserted either.

Setup
Setuprun as lab_a
CREATE TABLE members (id INT PRIMARY KEY, name VARCHAR(20), last_login DATETIME NULL);
CREATE TABLE members_csv (id INT, name VARCHAR(20), last_login VARCHAR(20));
INSERT INTO members_csv VALUES (1, 'Kim', '2026-11-29 09:10:00'), (2, 'Lee', '');
OUTPUT
Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0
Reproducerun as lab_a
INSERT INTO members SELECT id, name, last_login FROM members_csv;
✕ ERROR
ERROR 1292 (22007): Incorrect datetime value: '' for column 'last_login' at row 2
Check the causerun as lab_a
SELECT id, name, last_login, last_login = '' AS is_empty FROM members_csv;
OUTPUT
+------+------+---------------------+----------+
| id   | name | last_login          | is_empty |
+------+------+---------------------+----------+
|    1 | Kim  | 2026-11-29 09:10:00 |        0 |
|    2 | Lee  |                     |        1 |
+------+------+---------------------+----------+
2 rows in set (0.00 sec)

is_empty is 1 only for row 2 (Lee). That empty string is what the DATETIME column rejects.

Turn empty strings into NULL with NULLIF(last_login, ''). Both rows are inserted and Lee's last_login is NULL.

Fix: run the corrected statementrun as lab_a
INSERT INTO members SELECT id, name, NULLIF(last_login, '') FROM members_csv;
SELECT * FROM members;
✓ SUCCESS
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

+----+------+---------------------+
| id | name | last_login          |
+----+------+---------------------+
|  1 | Kim  | 2026-11-29 09:10:00 |
|  2 | Lee  | NULL                |
+----+------+---------------------+
2 rows in set (0.00 sec)

030000-00-00 used for "no date"

Old MySQL schemas often used '0000-00-00' for an empty end date. The session sql_mode contains NO_ZERO_DATE, so it is rejected.

Setup
Setuprun as lab_a
CREATE TABLE contracts (id INT PRIMARY KEY, end_date DATE NULL);
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Reproducerun as lab_a
INSERT INTO contracts VALUES (1, '0000-00-00');
✕ ERROR
ERROR 1292 (22007): Incorrect date value: '0000-00-00' for column 'end_date' at row 1
Check the causerun as lab_a
SELECT FIND_IN_SET('NO_ZERO_DATE', @@SESSION.sql_mode) > 0 AS no_zero_date,
       (SELECT is_nullable FROM information_schema.columns
         WHERE table_schema = DATABASE() AND table_name = 'contracts' AND column_name = 'end_date') AS end_date_nullable;
OUTPUT
+--------------+-------------------+
| no_zero_date | end_date_nullable |
+--------------+-------------------+
|            1 | YES               |
+--------------+-------------------+
1 row in set (0.01 sec)

no_zero_date is 1, so the session rejects '0000-00-00'. end_date_nullable is YES, so the column can store NULL instead.

Make the column nullable and store NULL for "no end date". Query it with end_date IS NULL. Changing sql_mode to accept zero dates was not tested here.

Fix: run the corrected statementrun as lab_a
INSERT INTO contracts VALUES (1, NULL);
SELECT id, end_date, end_date IS NULL AS no_end FROM contracts;
✓ SUCCESS
Query OK, 1 row affected (0.00 sec)

+----+----------+--------+
| id | end_date | no_end |
+----+----------+--------+
|  1 | NULL     |      1 |
+----+----------+--------+
1 row in set (0.00 sec)

04A day that does not exist, such as February 30

'2026-02-30' has the right format but is not a real date. Month-end dates built by string concatenation often end up like this.

Setup
Setuprun as lab_a
CREATE TABLE closings (id INT PRIMARY KEY, close_date DATE);
OUTPUT
Query OK, 0 rows affected (0.02 sec)
Reproducerun as lab_a
INSERT INTO closings VALUES (1, '2026-02-30');
✕ ERROR
ERROR 1292 (22007): Incorrect date value: '2026-02-30' for column 'close_date' at row 1
Check the causerun as lab_a
SELECT DAY(LAST_DAY('2026-02-01')) AS feb_days;
OUTPUT
+----------+
| feb_days |
+----------+
|       28 |
+----------+
1 row in set (0.00 sec)

February 2026 has 28 days (feb_days = 28), so day 30 does not exist.

Let MySQL compute the month end: LAST_DAY('2026-02-01') returns 2026-02-28.

Fix: run the corrected statementrun as lab_a
INSERT INTO closings VALUES (1, LAST_DAY('2026-02-01'));
SELECT * FROM closings;
✓ SUCCESS
Query OK, 1 row affected (0.01 sec)

+----+------------+
| id | close_date |
+----+------------+
|  1 | 2026-02-28 |
+----+------------+
1 row in set (0.00 sec)

05Inserting a JavaScript toISOString() value ('…T10:00:00.000Z') as is

'2026-11-30T10:00:00.000Z' sent from new Date().toISOString() is rejected by the DATETIME column because of the trailing Z (UTC marker).

Setup
Setuprun as lab_a
CREATE TABLE events (id INT PRIMARY KEY, happened_at DATETIME);
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Reproducerun as lab_a
INSERT INTO events VALUES (1, '2026-11-30T10:00:00.000Z');
✕ ERROR
ERROR 1292 (22007): Incorrect datetime value: '2026-11-30T10:00:00.000Z' for column 'happened_at' at row 1
Check the causerun as lab_a
SELECT CAST('2026-11-30T10:00:00.000' AS DATETIME) AS without_z, @@session.time_zone AS tz;
OUTPUT
+---------------------+--------+
| without_z           | tz     |
+---------------------+--------+
| 2026-11-30 10:00:00 | SYSTEM |
+---------------------+--------+
1 row in set (0.00 sec)

The same value without the trailing Z converts to 2026-11-30 10:00:00, so the Z is the only problem. The session time_zone is SYSTEM.

Replacing Z with +00:00 makes MySQL read it as a time zone offset. The session time_zone in this lab is SYSTEM (UTC), so it was stored as 2026-11-30 10:00:00. With a different session time zone, the value is converted to that zone.

Fix: run the corrected statementrun as lab_a
INSERT INTO events VALUES (1, REPLACE('2026-11-30T10:00:00.000Z', 'Z', '+00:00'));
SELECT * FROM events;
✓ SUCCESS
Query OK, 1 row affected (0.01 sec)

+----+---------------------+
| id | happened_at         |
+----+---------------------+
|  1 | 2026-11-30 10:00:00 |
+----+---------------------+
1 row in set (0.00 sec)

FAQ

How do I fix MySQL error 1292 Incorrect date value?

Look at the value in the message. Convert other formats with STR_TO_DATE, use NULL instead of '' or 0000-00-00, and check that the day really exists.

How do I insert an empty string into a DATETIME column?

You cannot in strict mode. Insert NULL instead, for example with NULLIF(col, '').

Why is 0000-00-00 not allowed in MySQL 8?

The default sql_mode includes NO_ZERO_DATE and strict mode, so zero dates are rejected. Use NULL for missing dates.

How do I convert dd/mm/yyyy to a date in MySQL?

STR_TO_DATE('30/11/2026', '%d/%m/%Y') returns 2026-11-30.

How do I insert an ISO date like '2026-11-30T10:00:00.000Z' into a MySQL DATETIME?

The trailing Z causes error 1292. Use REPLACE(value, 'Z', '+00:00') to give it an offset. The stored value is converted to the session time_zone.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13