WEEKOFYEAR( )

This MySQL function returns the calendar week of the year for a given date. It's a bit synonymous with WEEK( ).

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

WEEKOFYEAR(date)

Explanation

This function returns the calendar week of the year for a given date. This function was added in version 4.1.1 of MySQL. It's synonymous with WEEK( ), but with the mode of 3 for that function only. There's no way to change the mode for this function.

Examples

SELECT CURDATE( ) AS Date,
WEEKOFYEAR(CURDATE( )) AS Week;

+------------+------+
| Date       | Week |
+------------+------+
| 2005-01-11 |    2 |
+------------+------+