Retrieve the week number corresponding to a specific date.
SELECT WEEKOFYEAR(“2017-06-15”); |
The WEEKOFYEAR() function returns the week number (from 1 to 53) for a specified date.
Note: Assuming Monday is the first day of the week and the first week of the year has more than 3 days.
Tip: Also consider using the WEEK()
function.
WEEKOFYEAR(date) |
Parameter |
Description |
date |
Required: The date or datetime from which to extract the week number. |
Works in: |
From MySQL version 4.0 |
Retrieve the week number corresponding to a specific date.
SELECT WEEKOFYEAR(“2017-01-01”); |
Retrieve the week number for the current date according to the system’s configuration.
SELECT WEEKOFYEAR(CURDATE()); |