Home »
MySQL »
MySQL date/time Functions
MySQL DATEDIFF() Function
MySQL | DATEDIFF() Function: Learn about the DATEDIFF() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 04, 2022
DATEDIFF() Function
Whenever you want to find out the difference between two dates then DATEDIFF() function is used. This function gives you the exact number of differences between two dates.
DATEDIFF() Syntax
SELECT DATEDIFF(date1, date2);
DATEDIFF() Parameter(s)
For this function, it is important to give two dates as the parameter.
DATEDIFF() Return Value
The function will return the number (number of days) after calculating the difference between the two dates.
MySQL DATEDIFF() Function Example 1
SELECT DATEDIFF('2022-04-12','2001-04-12');
MySQL DATEDIFF() Function Example 2
SELECT DATEDIFF('2022-08-05','2022-08-05');