일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- String Functions and Operators
- Sring Functions and Operators
- Tibero
- SVN
- MySQL
- Oracle
- Date and Time Functions
- Date and Time Function
- 티베로
- HTTP
- 방화벽
- 윈도우
- 오라클
- 전자정부표준프레임워크
- 전자정부 표준프레임워크
- Data and Time Functions
- String Functions and Date Operators
- String Function and Operators
- Today
- Total
웹이야기
MySQL TIMESTAMPDIFF() 본문
MySQL 날짜함수, 시간함수
TIMESTAMPDIFF()
-
TIMESTAMPDIFF(unit, datetime_expr1, datetime_expr2)
의 형태
Returns datetime_expr2 - datetime_expr1, where datetime_expr1 and datetime_expr2 are date or datetime expressions. One expression may be a date and the other a datetime: a date value is treated as a datetime having the time part '00:00:00' where necessary. The unit for the result (an integer) is given by the unit argument. The legal values for unit are the same those listed in the description of the TIMESTAMPADD function.
mysql> SELECT TIMESTAMPDIFF(MONTH, '2020-04-01', '2020-10-01');
+--------------------------------------------------+
| TIMESTAMPDIFF(MONTH, '2020-04-01', '2020-10-01') |
+--------------------------------------------------+
| 6 |
+--------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT TIMESTAMPDIFF(YEAR, '2020-04-01', '2020-10-01');
+-------------------------------------------------+
| TIMESTAMPDIFF(YEAR, '2020-04-01', '2020-10-01') |
+-------------------------------------------------+
| 0 |
+-------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT TIMESTAMPDIFF(SECOND, '2020-04-01 05:34:55', '2020-10-10 23:32:55');
+---------------------------------------------------------------------+
| TIMESTAMPDIFF(SECOND, '2020-04-01 05:34:55', '2020-10-10 23:32:55') |
+---------------------------------------------------------------------+
| 16653480 |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)
'D > MySQL' 카테고리의 다른 글
MySQL TIME_TO_SEC() (0) | 2020.04.05 |
---|---|
MySQL TIME_FORMAT() (0) | 2020.04.04 |
MySQL TIMESTAMPADD() (0) | 2020.04.04 |
MySQL TIMESTAMP() (0) | 2020.04.04 |
MySQL TIMEDIFF() (0) | 2020.04.03 |