mysql> mysql> SELECT WEEK('2001-12-26'); +--------------------+ | WEEK('2001-12-26') | +--------------------+ | 51 | +--------------------+ 1 row in set (0.00 sec) mysql>
Without a second parameter, WEEK(date) assumes that
mysql> mysql> select WEEK('2000-01-01'); +--------------------+ | WEEK('2000-01-01') | +--------------------+ | 0 | +--------------------+ 1 row in set (0.00 sec) mysql>
You can add the firstday parameter.
0 representing Sunday, 1=Monday, and so on.
mysql> mysql> select WEEK('2000-01-09'); +--------------------+ | WEEK('2000-01-09') | +--------------------+ | 2 | +--------------------+ 1 row in set (0.00 sec) mysql> select WEEK('2000-01-09',1); --you told MySQL to start counting from the Monday +----------------------+ | WEEK('2000-01-09',1) | +----------------------+ | 1 | +----------------------+ 1 row in set (0.00 sec)
14.55.WEEK | ||||
14.55.1. | WEEK(date[,mode]) returns the week number for date | |||
14.55.2. | WEEK(date), parameter, returns the week of the year in the range 0 to 53: |