웹이야기

MySQL TIMEDIFF() 본문

D/MySQL

MySQL TIMEDIFF()

yeon.Biju 2020. 4. 3. 17:21

MySQL 날짜함수, 시간함수

 

TIMEDIFF()

   - 시간의 차이를 구해주는 함수.

 

TIMEDIFF(expr1, expr2)

의 형태

 

TIMEDIFF() returns expr1 - expr2 expressed a s a TIME value. expr1 and expr2 are time or date-and-time expressions, but both must be of the same type.

 

The resuilt returned by TIMEDIFF() is limited to the range allowed for TIME vlaues. Alternatively , you can use either of the functions TIMESTAMPDIFF() and UNIX_TIMESTAMP(), both of which return integers.

 

mysql> SELECT TIMEDIFF('2020-04-03 22:21:20', '2020-03-01 11;11:11');
+--------------------------------------------------------+
| TIMEDIFF('2020-04-03 22:21:20', '2020-03-01 11;11:11') |
+--------------------------------------------------------+
| 803:10:09                                              |
+--------------------------------------------------------+
1 row in set (0.00 sec)

 

 


mysql> SELECT TIMEDIFF('2020-04-03 22:21:20', '2020-03-01 11;11:11.777777');
+---------------------------------------------------------------+
| TIMEDIFF('2020-04-03 22:21:20', '2020-03-01 11;11:11.777777') |
+---------------------------------------------------------------+
| 803:10:08.222223                                              |
+---------------------------------------------------------------+
1 row in set (0.00 sec)

 

 

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

MySQL TIMESTAMPADD()  (0) 2020.04.04
MySQL TIMESTAMP()  (0) 2020.04.04
MySQL TIME()  (0) 2020.04.03
MySQL SYSDATE()  (0) 2020.04.03
MySQL SUBTIME()  (0) 2020.04.03
Comments