Date Time Functions MySQL Tutorial

Only the date parts of the values are used in the calculation.

mysql>
mysql> SELECT DATEDIFF('1997-12-31 23:59:59','1997-12-30');
+----------------------------------------------+
| DATEDIFF('1997-12-31 23:59:59','1997-12-30') |
+----------------------------------------------+
|                                            1 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql> SELECT DATEDIFF('1997-11-30 23:59:59','1997-12-31');
+----------------------------------------------+
| DATEDIFF('1997-11-30 23:59:59','1997-12-31') |
+----------------------------------------------+
|                                          -31 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql>