MySQL DATEDIFF() function returns the number of days between two dates. The syntax of this function is as follows −
DATEDIFF(date1,date2)
For example, if we want to know a number of days between dates say ‘2017-10-22’ and ‘2017-09-21’ then we can use DATEDIFF() function as follows −
mysql> Select DATEDIFF('2017-10-22','2017-09-21') AS 'NUMBER OF DAYS'; +----------------+ | NUMBER OF DAYS | +----------------+ | 31 | +----------------+ 1 row in set (0.00 sec)