Archive
Posts Tagged ‘YEARWEEK’
Function to find dates in current week in mysql
May 19, 2016
Leave a comment
MySQL YEARWEEK() returns year and week number for a given date.
Syntax: YEARWEEK(date_value,Mode)
Parameters or Arguments
- date_value
- A date or datetime value from which to extract the year and week.
- mode
- Optional. It is used to specify what day the week starts on. It can be one of the following:
mode Explanation Week Value 0 First day of the week is Sunday 0-53 1 First day of the week is Monday and the first week has more than 3 days 0-53 2 First day of the week is Sunday 1-53 3 First day of the week is Monday and the first week has more than 3 days 1-53 4 First day of the week is Sunday and the first week has more than 3 days 0-53 5 First day of the week is Monday 0-53 6 First day of the week is Sunday and the first week has more than 3 days 1-53 7 First day of the week is Monday 1-53
Example : select YEARWEEK(now());
The following statement will return the year and week number of the date 2016-05-19.
SELECT YEARWEEK(‘2016-05-19’);
Hope this help!
Categories: Sql Server
add days, current week, date, MySQL, SQL, YEARWEEK
Comments