MySQL YEARWEEK function is one of the MySQL Date Functions, which returns the Year and Week of the given date. The mode argument in this YearWeek function works exactly the same as the Week() function
In this article, we show you how to use this YearWeek function to get the calendar year and Week number in MySQL with an example. The basic syntax of the YearWeek() Function in MySQL is as shown below:
Here, Mode is an optional argument. For example, if Mode = 0, then the week starts on Sunday, and the return value is between 0 and 53.
MySQL YEARWEEK function Example
The following examples help you understand the use of this YEARWEEK function. Here, we are returning the calendar Year and week number of different dates.
SELECT YEARWEEK('2018-12-31', 6);
SELECT YEARWEEK('2018-01-01', 2);
SELECT YEARWEEK('2018-01-01', 7);
Please refer to MySQL Week() function example.