MySQL DATEDIFF()
MySQL 날짜함수, 시간함수
DATEDIFF()
- 날짜의 차이를 구하는 함수. expr1 - expr2.
DATEDIFF(expr1, expr2)
DATEDIFF() returns expr1 - expr2 expressed as a value in days from one date to other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation
mysql> SELECT DATEDIFF('2007-12-31 23:59:59','2007-12-30');
+----------------------------------------------+
| DATEDIFF('2007-12-31 23:59:59','2007-12-30') |
+----------------------------------------------+
| 1 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT DATEDIFF(NOW(), CURDATE());
+-----------------------------+
| DATEDIFF(NOW(), CURDATE()) |
+-----------------------------+
| 0 |
+-----------------------------+
1 row in set (0.00 sec)