mysql에서 week(date)

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 from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used. See Section 5.1.5, “Server System Variables”.

The following table describes how the mode argument works.

ModeFirst day of weekRangeWeek 1 is the first week …
0Sunday0-53with a Sunday in this year
1Monday0-53with 4 or more days this year
2Sunday1-53with a Sunday in this year
3Monday1-53with 4 or more days this year
4Sunday0-53with 4 or more days this year
5Monday0-53with a Monday in this year
6Sunday1-53with 4 or more days this year
7Monday1-53with a Monday in this year

For mode values with a meaning of with 4 or more days this year, weeks are numbered according to ISO 8601:1988:

  • If 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.


(출처: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_week)


그런데 내가 요청받은 것.

토요일부터 금요일까지를 한주로 계산해서 뽑아주세요...

힝....


'개발개발 > mySql' 카테고리의 다른 글

DB를 쿼리로 업데이트 할때  (0) 2018.09.16
mysql 월/주차 구하기  (1) 2018.01.06
left join 시 속도 문제  (0) 2016.12.20
SELECT 정렬하기 정리  (0) 2016.12.13
order by varchar to int  (0) 2016.11.24

+ Recent posts