86
MySQL Date/Time week() Function
The week() is a MySQL date/time function. It is used to get the week portion from given date.
Syntax
Parameter:
Date_value : date for getting week
Mode : it is optional. It is used to specify what day the week starts on. It can be one of the following:
Mode | Explanation | Returns |
---|---|---|
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 |
Returns:
This function returns the week portion of a date value.
Example 1
Output:
Example 2
Output:
Next TopicMySQL datetime