This tutorial explains how to use the MySQL WEEKOFYEAR function with syntax and examples.
The MySQL WEEKOFYEAR function returns week of the year for a date value.
The syntax for the WEEKOFYEAR function in MySQL is:
WEEKOFYEAR( date_value )
A date or datetime value from which to extract the week of the year.
The WEEKOFYEAR function can be used in the following versions of MySQL:
Let's look at some MySQL WEEKOFYEAR function examples and explore how to use the WEEKOFYEAR function in MySQL.
For example:
mysql> SELECT WEEKOFYEAR('2014-01-01');
Output: 1
mysql> SELECT WEEKOFYEAR('2014-02-28');
Output: 9
mysql> SELECT WEEKOFYEAR('2014-12-28');
Output: 52
This last WEEKOFYEAR example would display the week of the year for the current system date (current system date is returned by the CURDATE function).
mysql> SELECT WEEKOFYEAR(CURDATE());