웹이야기

MySQL SUBTIME() 본문

D/MySQL

MySQL SUBTIME()

yeon.Biju 2020. 4. 3. 16:54

MySQL 날짜함수, 시간함수

 

SUBTIME()

   - 시간을 빼는 함수

 

SUBTIME(expr1, expr2)

의 형태

 

SUBTIME() returns expr1 - expr2 expressed as a value in the same format as expr1. expr1 is a time or datetime expression, and expr2 is a time expression.

 

mysql> SELECT SUBTIME('2007-12-31 23:59:59', '1 1:1:1.000002');
+--------------------------------------------------+
| SUBTIME('2007-12-31 23:59:59', '1 1:1:1.000002') |
+--------------------------------------------------+
| 2007-12-30 22:58:57.999998                       |
+--------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT SUBTIME('01:00:00.999999' ,'02:00:00.999999');
+-----------------------------------------------+
| SUBTIME('01:00:00.999999' ,'02:00:00.999999') |
+-----------------------------------------------+
| -01:00:00                                     |
+-----------------------------------------------+
1 row in set (0.01 sec)

 

mysql> SELECT SUBTIME('03:00:00' ,'02:00:00');
+---------------------------------+
| SUBTIME('03:00:00' ,'02:00:00') |
+---------------------------------+
| 01:00:00                        |
+---------------------------------+
1 row in set (0.00 sec)

mysql> SELECT SUBTIME('03:00:00' ,'02:00:00')+0;
+-----------------------------------+
| SUBTIME('03:00:00' ,'02:00:00')+0 |
+-----------------------------------+
|                             10000 |
+-----------------------------------+
1 row in set (0.00 sec)

 

 

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

MySQL TIME()  (0) 2020.04.03
MySQL SYSDATE()  (0) 2020.04.03
MySQL SUBDATE()  (0) 2020.04.03
MySQL STR_TO_DATE()  (0) 2020.04.03
MySQL SEC_TO_TIME()  (0) 2020.04.03
Comments