TO_DAYS function returns incorrect value

Bug #420029 reported by Lee Bieber
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Drizzle
Fix Released
Low
Mark Atwood

Bug Description

In the crash-me test there is a check for TO_DAYS function. Drizzle is returning an incorrect value. The TO_DAYS function takes a date argument and is suppose to return the number of days since the year 0. Note that we should add a test to our test suite for this once this bug is fixed

drizzle> select to_days('1996-01-01');
+-----------------------+
| to_days('1996-01-01') |
+-----------------------+
| 2450084 | <------ should be 729024
+-----------------------+
1 row in set (0 sec)

drizzle> select to_days('0001-01-01');
+-----------------------+
| to_days('0001-01-01') |
+-----------------------+
| 1721426 | <----- should be 366
+-----------------------+
1 row in set (0 sec)

Related branches

Revision history for this message
Jay Pipes (jaypipes) wrote :

When reworking temporal values, I got rid of the MySQL-specific TO_DAYS() behaviour (of having a fictitious "day zero") in favor of the behaviour exhibited by almost all other databases, including PostgreSQL: use the Julian Day Number, which is the number of days since -4713 B.C. MySQL believes that there is a "year 0", which there is not.

I believe this is more a documentation issue than a bug in the output of TO_DAYS()...

Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

I've updated the drizzle documentation on our wiki with this information

Changed in drizzle:
milestone: none → bell
status: New → Invalid
Changed in drizzle:
assignee: nobody → Mark Atwood (fallenpegasus)
importance: Undecided → Low
status: Invalid → Confirmed
Vijay Samuel (vjsamuel)
Changed in drizzle:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.