Bug #23795 Year < 0100 is misjudged in to_days() function
Submitted: 31 Oct 2006 8:37 Modified: 1 Nov 2006 12:15
Reporter: Kei SAKAI Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.11 OS:
Assigned to: CPU Architecture:Any

[31 Oct 2006 8:37] Kei SAKAI
Description:
when four digits year (under 0100, zero filled, like "0050") gives to to_days() function, it may interpreted to "2050". 

How to repeat:
mysql> select to_days("2050-01-01 00:00:01");
+--------------------------------+
| to_days("2050-01-01 00:00:01") |
+--------------------------------+
|                         748748 |
+--------------------------------+
1 row in set (0.00 sec)

mysql> select to_days("0050-01-01 00:00:01");  # MySQL judges not "0050" but "2050".
+--------------------------------+
| to_days("0050-01-01 00:00:01") |
+--------------------------------+
|                         748748 |
+--------------------------------+
1 row in set (0.00 sec)

mysql> select to_days("50-01-01 00:00:01");
+------------------------------+
| to_days("50-01-01 00:00:01") |
+------------------------------+
|                       748748 |
+------------------------------+
1 row in set (0.00 sec)
[1 Nov 2006 12:15] Valeriy Kravchuk
Sorry, but according to the manual (http://dev.mysql.com/doc/refman/5.1/en/datetime.html):

"The DATETIME type is used when you need values that contain both date and time information. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'."

So, year 50 is just not supported anywat, and 0050 is still converted to 2050, as described at http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html.

This is expected behaviour, I think.