I’ll try to clear up possible confusion about dates and MySQL’s TO_DAYS() function. TO_DAYS() works, correctly. TO_DAYS() assumes a year 0, correctly. There are indeed bugs, but only if you use MySQL extensions with partitions.
First: TO_DAYS() works, correctly. The MySQL Reference Manual
says we use a proleptic Gregorian calendar, and that’s all
explained with terms anyone can follow, in section “11.7. What
Calendar Is Used By MySQL?”
http://dev.mysql.com/doc/refman/5.1/en/mysql-calendar.html
So we follow the Gregorian rules, not the Julian ones, without
concerning ourselves about what happened in 1582 — just like DB2,
just like the standard, not like Oracle. To make sure it’s okay,
I wrote and ran this stored procedure:
DELIMITER // SET @@sql_mode=ansi// DROP procedure IF EXISTS p// CREATE PROCEDURE p () BEGIN DECLARE days_in_month INT DEFAULT 31; DECLARE months_in_year INT DEFAULT 12; DECLARE …[Read more]