Name

WEEKOFYEAR()

Synopsis

WEEKOFYEAR(date)

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

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

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

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.