일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Date and Time Functions
- 전자정부 표준프레임워크
- 전자정부표준프레임워크
- 오라클
- Data and Time Functions
- Tibero
- HTTP
- 방화벽
- String Functions and Operators
- SVN
- Sring Functions and Operators
- Oracle
- MySQL
- 티베로
- String Function and Operators
- Date and Time Function
- String Functions and Date Operators
- 윈도우
- Today
- Total
웹이야기
MySQL WEEK() 본문
MySQL 날짜함수, 시간함수
WEEK()
-
WEEK(date[, mode])
의 형태
This function returns the week number for date. The two-argument form of WEEK() enables you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used.
The following table describes how the mode argument works.
Mode | First day of week | Range | Week 1 is the first week... |
0 | Sunday | 0-53 | with a Sunday in this year |
1 | Monday | 0-53 | with 4 or more days days this year |
2 | Sunday | 1-53 | with a Sunday in this year |
3 | Monday | 1-53 | with 4 or more days this year |
4 | Sunday | 0-53 | with 4 or more days this year |
5 | Monday | 0-53 | with a Monday in this year |
6 | Sunday | 1-53 | with 4 or more days this ear |
7 | Monday | 1-53 | with a Monday in this year |
For mode values with a meaning of "with 4 mor more days this year", weeks are numbered according to ISO 8601:1988:
- It the week containing January 1 has 4 or more days in the new year, it is week 1.
- Otherwise, it is the last week of the previous year, and the next week is week 1.
mysql> SELECT WEEK(NOW());
+-------------+
| WEEK(NOW()) |
+-------------+
| 14 |
+-------------+
1 row in set (0.00 sec)
mysql> SELECT WEEK('2020-04-01');
+--------------------+
| WEEK('2020-04-01') |
+--------------------+
| 13 |
+--------------------+
1 row in set (0.00 sec)
mysql> SELECT WEEK('2020-04-01', 0);
+-----------------------+
| WEEK('2020-04-01', 0) |
+-----------------------+
| 13 |
+-----------------------+
1 row in set (0.00 sec)
mysql> SELECT WEEK('2020-04-01', 1);
+-----------------------+
| WEEK('2020-04-01', 1) |
+-----------------------+
| 14 |
+-----------------------+
1 row in set (0.00 sec)
'D > MySQL' 카테고리의 다른 글
MySQL WEEKOFYEAR() (0) | 2020.04.05 |
---|---|
MySQL WEEKDAY() (0) | 2020.04.05 |
MySQL UTC_TIMESTAMP() (0) | 2020.04.05 |
MySQL UTC_TIME() (0) | 2020.04.05 |
MySQL UTC_DATE() (0) | 2020.04.05 |