Bug #7329 DATE: implicit CAST gets incorrect result
Submitted: 15 Dec 2004 17:54 Modified: 15 Dec 2004 19:40
Reporter: Trudy Pelzer Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.3-alpha-debug OS:Linux (SuSE 9.1)
Assigned to: CPU Architecture:Any

[15 Dec 2004 17:54] Trudy Pelzer
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'
[15 Dec 2004 19:40] Dmitry Lenev
This is duplicate of bug #7297.