Description
The WEEK( ) function returns the week number for a date. There two-argument form of WEEK ( ) enables to specify whether the week starts from Sunday to Monday and whether the return value is in the range of 0 to 52 or 1 to 53.
This function has the form:
SELECT WEEK(date,mode)
Parameter | Description |
---|---|
date | A date |
mode | A number |
Return Value
Week number for a date.
Examples
The following example shows the basic use of this function:
mysql> SELECT WEEK('2008-02-20');
-> 7
mysql> SELECT WEEK('2008-02-20',0);
-> 7
mysql> SELECT WEEK('2008-02-20',1);
-> 8
mysql> SELECT WEEK('2008-12-31',1);
-> 53