웹이야기

MySQL DATEDIFF() 본문

D/MySQL

MySQL DATEDIFF()

yeon.Biju 2020. 4. 1. 15:00

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)

 

 

'D > MySQL' 카테고리의 다른 글

MySQL DATE_FORMAT()  (0) 2020.04.01
MySQL DATE_ADD(), DATE_SUB()  (0) 2020.04.01
MySQL DATE()  (0) 2020.04.01
MySQL CURRENT_TIMESTAMP, CURRENT_TIMESTAMP()  (0) 2020.04.01
MySQL CURRENT_TIME, CURRENT_TIME()  (0) 2020.04.01
Comments