웹이야기

MySQL YEARWEEK() 본문

D/MySQL

MySQL YEARWEEK()

yeon.Biju 2020. 4. 5. 13:41

MySQL 날짜함수, 시간함수

 

YEARWEEK()

   -

 

YEARWEEK(date), YEARWEEK(date, mode)

의 형태

 

Returns year and week for a date. The year in the result may be different form the year in the date argument for the first and the last week of the year.

 

The mode argument works exactll like the mode argument to WEEK(). For the single-argument syntax, a mode value of 0 is used. Unlike WEEK(), the value of default_week_format does not influence YEARWEEK().

 

mysql> SELECT YEARWEEK(NOW());
+-----------------+
| YEARWEEK(NOW()) |
+-----------------+
|          202014 |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT YEARWEEK('2020-04-05');
+------------------------+
| YEARWEEK('2020-04-05') |
+------------------------+
|                 202014 |
+------------------------+
1 row in set (0.00 sec)

 

The week number is different from what the WEEK() function would return (0) for optional arguments 0 or 1, as WEEK() then returns the week in the context of the given year. 

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

[MySQL] ASCII()  (0) 2020.04.08
MySQL String Function and Operators  (0) 2020.04.07
MySQL YEAR()  (0) 2020.04.05
MySQL WEEKOFYEAR()  (0) 2020.04.05
MySQL WEEKDAY()  (0) 2020.04.05
Comments