Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL)
Description
MariaDB 10.1 |
MariaDB [test]> SELECT STR_TO_DATE('1949-02-30','%Y-%m-%d'); |
+--------------------------------------+ |
| STR_TO_DATE('1949-02-30','%Y-%m-%d') | |
+--------------------------------------+ |
| 1949-02-30 |
|
+--------------------------------------+ |
1 row in set (0.00 sec) |
According to specification, it should be NULL for invalid date values.
Reproducible with MySQL 5.5/5.6, but fixed in MySQL 5.7 (only it produces duplicate warnings, let's not do it):
MySQL 5.7 |
MySQL [test]> SELECT STR_TO_DATE('1949-02-30','%Y,%m,%d'); |
+--------------------------------------+ |
| STR_TO_DATE('1949-02-30','%Y,%m,%d') | |
+--------------------------------------+ |
| NULL | |
+--------------------------------------+ |
1 row in set, 2 warnings (0.00 sec) |
 |
MySQL [test]> show warnings;
|
+---------+------+-----------------------------------------------------------------+ |
| Level | Code | Message | |
+---------+------+-----------------------------------------------------------------+ |
| Warning | 1411 | Incorrect datetime value: '1949-02-30' for function str_to_date | |
| Warning | 1411 | Incorrect datetime value: '1949-02-30' for function str_to_date | |
+---------+------+-----------------------------------------------------------------+ |
2 rows in set (0.00 sec) |
Found on stackoverflow.