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
Sunday is the first day of the week
at the beginning of the year
any days before the 'first day' come in week 0.
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)