April 2008
Intermediate to advanced
566 pages
21h 55m
English
DATEDIFF()
DATEDIFF(date,date)
This function returns the number of days of difference between the two dates given. Although a parameter may be given in date and time format, only the dates are used for determining the difference. This function is available as of version 4.1.1 of MySQL. Here is an example:
SELECT CURDATE( ) AS Today,
DATEDIFF('2008-12-25', NOW( ))
AS 'Days to Christmas';
+------------+-------------------+
| Today | Days to Christmas |
+------------+-------------------+
| 2008-03-14 | 286 |
+------------+-------------------+Read now
Unlock full access