| Bug #3161 | to_days() returns wrong value | ||
|---|---|---|---|
| Submitted: | 12 Mar 2004 14:36 | Modified: | 22 Mar 2004 9:07 |
| Reporter: | Max Matson | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
| Version: | 4.0.18 | OS: | MacOS (Mac OSX 10.3.3) |
| Assigned to: | Paul DuBois | CPU Architecture: | Any |
[12 Mar 2004 14:45]
Max Matson
mysqlbugs report
Attachment: mysqlbugTO_DAYS.txt (text/plain), 3.05 KiB.
[17 Mar 2004 8:31]
Dean Ellis
I am verifying this as a documentation issue. Years < 200 are treated as 1900-2100 (ie: "0090-03-15", "1990-03-15").
[22 Mar 2004 9:07]
Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant product(s).

Description: to_days() returns wrong integer for some early dates. For dates from '0001-01-01' thru '0199-12-01' give values 730851 thru 767009 respectively. The value given by to_days for these dates correspond to dates greater than '2001-01-01', but not directly to the period '2001-01-01' through '2199-12-31'. How to repeat: -- wrong values for 0001-01-01 thru 0199-12-31 mysql> select to_days('0199-12-31'); +-----------------------+ | to_days('0199-12-31') | +-----------------------+ | 767009 | +-----------------------+ -- first correct value mysql> select to_days('0200-01-01'); +-----------------------+ | to_days('0200-01-01') | +-----------------------+ | 73049 | +-----------------------+ Suggested fix: Even though the documentation declairs the to_days() and from_days() functions as not being intended for use prior to year 1582, the functions shouldn't return values valid for dates later than 1582 from dates prior to it. It would be nice to have the functions return the serial number from 1-1-0001 to 12-31-9999 as an increment of the number of days since 1-1-0001 given that it is not the true count of days prior to 1582. If need be, the first serial number could be adjusted by 10 to help account for the changes made to the Gregorian calendar in 1582.