How can we allow MySQL to store invalid dates?


After enabling the SQL MODE to ALLOW_INVALID_DATES, MySQL will also be able to store invalid dates in the table. The example is given below to understand it −

mysql> Insert into order1234(ProductName, Quantity, Orderdate) values('B',500,'2015-11-31');
Query OK, 1 row affected (0.06 sec)

mysql> Select * from order1234;
+-------------+----------+--------------+
| ProductName | Quantity | OrderDate    |
+-------------+----------+--------------+
| A           | 500      | 0000-00-00   |
| B           | 500      | 2015-11-31   |
+-------------+----------+--------------+
2 rows in set (0.00 sec)

We can see MySQL also inserts the invalid date in a table.

Updated on: 28-Jan-2020

218 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements