Name
YEARWEEK( )
Synopsis
YEARWEEK(date
[,value
])
This function returns the year coupled with the number of the week into the year: yyyyww. By default, the first day of the week is Sunday and the basis of the calculation. Optionally, you can set this to Monday as the first day of the week by entering a value of 1 for the second argument.
SELECT YEARWEEK('2005-01-07') AS 'YearWeek'; +----------+ | YearWeek | +----------+ | 200501 | +----------+
This function may be useful in
conjunction with the PERIOD_ADD( )
and
PERIOD_DIFF( )
functions.
Get MySQL in a Nutshell 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.