| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- MySQL
- HTTP
- String Functions and Date Operators
- 전자정부표준프레임워크
- String Functions and Operators
- 오라클
- Sring Functions and Operators
- Date and Time Functions
- Date and Time Function
- SVN
- 전자정부 표준프레임워크
- 윈도우
- Data and Time Functions
- String Function and Operators
- 티베로
- Oracle
- 방화벽
- Tibero
- Today
- Total
웹이야기
MySQL PERIOD_DIFF() 본문
MySQL 날짜함수, 시간함수
PERIOD_DIFF()
- 두 인자의 개월 수 차이를 구한다.
PERIOD_DIFF(P1, P2)
의 형태
P1 -P2 이다.
Returns the number of months between periods P1 and P2. P1 and P2 should be in the foramt YYMM or YYYYMM. Note that the period arguments P1 and P2 are not date values.
mysql> SELECT PERIOD_DIFF(202001, 202001);
+-----------------------------+
| PERIOD_DIFF(202001, 202001) |
+-----------------------------+
| 0 |
+-----------------------------+
1 row in set (0.00 sec)
mysql> SELECT PERIOD_DIFF(202010, 202001);
+-----------------------------+
| PERIOD_DIFF(202010, 202001) |
+-----------------------------+
| 9 |
+-----------------------------+
1 row in set (0.00 sec)
mysql> SELECT PERIOD_DIFF(202001, 202010);
+-----------------------------+
| PERIOD_DIFF(202001, 202010) |
+-----------------------------+
| -9 |
+-----------------------------+
1 row in set (0.00 sec)
'D > MySQL' 카테고리의 다른 글
| MySQL SECOND() (0) | 2020.04.03 |
|---|---|
| MySQL QUARTER() (0) | 2020.04.02 |
| MySQL PERIOD_ADD() (0) | 2020.04.02 |
| MySQL NOW() (0) | 2020.04.02 |
| MySQL MONTHNAME() (0) | 2020.04.02 |