Bug #3101 Manual Date Error
Submitted: 7 Mar 2004 23:13 Modified: 22 Mar 2004 8:18
Reporter: Kevin Waterson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:4.1.1 OS:
Assigned to: Paul DuBois CPU Architecture:Any

[7 Mar 2004 23:13] Kevin Waterson
Description:
On the MySQL site the manual on page
http://www.mysql.com/doc/en/Date_and_time_functions.html
states the following for DATEDIFF...
DATEDIFF(expr,expr2)
    DATEDIFF() returns the number of days between the start date expr and the end date expr2. expr and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.

mysql> SELECT DATEDIFF('1997-12-31 23:59:59','1997-12-30');
        -> 1
mysql> SELECT DATEDIFF('1997-11-31 23:59:59','1997-12-31');
        -> -30

    DATEDIFF() was added in MySQL 4.1.1.

November, the 11th month, has only 30 days

How to repeat:
Simply look at http://www.mysql.com/doc/en/Date_and_time_functions.html

Suggested fix:
mysql> SELECT DATEDIFF('1997-11-30 23:59:59','1997-12-31');
-> -29
[8 Mar 2004 8:21] Dean Ellis
"Nov 31" becomes "Dec 01"; the return value is technically correct (also there is a 31 day difference between Nov 30 and Dec 31, rather than 29).

However, I'm going to verify this as a documentation issue, as the example should either use a real date or call attention to the conversion.  Thank you.
[22 Mar 2004 8:18] 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).

Additional info:

I changed the example to use 11-30 rather than 11-31.
Thanks.