SelectDATEDIFF('2017-10-22','2017-09-21')AS'NUMBEROFDAYS';+--------"/> SelectDATEDIFF('2017-10-22','2017-09-21')AS'NUMBEROFDAYS';+--------">

Home  >  Article  >  Database  >  How does the MySQL DATEDIFF() function work?

How does the MySQL DATEDIFF() function work?

WBOY
WBOYforward
2023-09-07 18:45:10689browse

MySQL DATEDIFF() 函数如何工作?

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 the number of days between "2017-10-22" and "2017-09-21", then we can use the DATEDIFF() function as follows Show-

mysql> Select DATEDIFF('2017-10-22','2017-09-21') AS 'NUMBER OF DAYS';

+----------------+
| NUMBER OF DAYS |
+----------------+
|            31  |
+----------------+
1 row in set (0.00 sec)

The above is the detailed content of How does the MySQL DATEDIFF() function work?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete