MySQL DATEDIFF()Function
MySQL Date Functions
Definition and Usage
The DATEDIFF() function returns the number of days between two dates.
Syntax
DATEDIFF(date1,date2)
The date1 and date2 parameters are valid date or date/time expressions.
Note:Only the date part of the values takes part in the calculation.
Example
The following is the SELECT statement:
SELECT DATEDIFF('2008-11-30','2008-11-29') AS DiffDate
The result is shown as follows:
| DiffDate |
|---|
| 1 |
Example
The following is the SELECT statement:
SELECT DATEDIFF('2008-11-29','2008-11-30') AS DiffDate
The result is shown as follows:
| DiffDate |
|---|
| -1 |
MySQL Date Functions Other Extensions