YEARWEEK(): function in a mysql date and time field
Returns the year & week from a date .
Output is 201638
For a invalid date we will get Null as output
Output is NULL
Understanding Mode (Optional Parameter , value 0 to 7)The week can start on Sunday or Monday,
To understand uses of MODE, read WEEK() function
If mode is not given, then it is considered as 0. The default_week_format of the MySQL system variables is not considered in YEARWEEK() function like WEEK() function. This is the main difference while using MODE between WEEK() function and YEARWEEK() function.
2012-01-01 change the First Day of Week to Monday
2018-01-01 select Sunday as First Day of Week
This article is written by plus2net.com team.
▼ More on Date & Time functions in SQL