Description:
When a string that does not exactly represent a valid
date is assigned to a DATE column, MySQL does an
implicit CAST to a DATE if possible. In the case where
the string is interpreted as having a 2-digit year, the
usual response is to add the current century to the
value. But this is not always happening; sometimes
the century value is CAST as "00" instead.
How to repeat:
mysql> create table t1 (col1 date);
mysql> insert into t1 values ('12:00:00');
Query OK, 1 row affected (0.00 sec)
-- This value would normally be interpreted as the date
'2012-00-00'; i.e. current century (20), year 12, month 00,
and day 00 of that month.
mysql> select * from t1;
+------------+
| col1 |
+------------+
| 0012-00-00 |
+------------+
1 row in set (0.00 sec)
-- This is not the correct result, which should be
'2012-00-00'
Description: When a string that does not exactly represent a valid date is assigned to a DATE column, MySQL does an implicit CAST to a DATE if possible. In the case where the string is interpreted as having a 2-digit year, the usual response is to add the current century to the value. But this is not always happening; sometimes the century value is CAST as "00" instead. How to repeat: mysql> create table t1 (col1 date); mysql> insert into t1 values ('12:00:00'); Query OK, 1 row affected (0.00 sec) -- This value would normally be interpreted as the date '2012-00-00'; i.e. current century (20), year 12, month 00, and day 00 of that month. mysql> select * from t1; +------------+ | col1 | +------------+ | 0012-00-00 | +------------+ 1 row in set (0.00 sec) -- This is not the correct result, which should be '2012-00-00'