MySQL YEARWEEK() 函数
示例
返回日期的年份和周数:
SELECT YEARWEEK("2017-06-15");
亲自试一试 »
定义和用法
YEARWEEK() 函数返回给定日期的年份和周数(0 到 53 之间的数字)。
语法
YEARWEEK(
date,
firstdayofweek)
参数值
Parameter |
Description |
date |
Required. The date or datetime value to extract the year and week number from |
firstdayofweek |
Optional. Specifies what day the week starts on. Can be one of the following:
- 0 - First day of week is Sunday
- 1 - First day of week is Monday and the first week has more than 3 days
- 2 - First day of week is Sunday
- 3 - First day of week is Monday and the first week has more than 3 days
- 4 - First day of week is Sunday and the first week has more than 3 days
- 5 - First day of week is Monday
- 6 - First day of week is Sunday and the first week has more than 3 days
- 7 - First day of week is Monday
|
技术细节
更多示例
示例
返回日期的年份和周数:
SELECT YEARWEEK("2017-10-25");
亲自试一试 »
示例
返回当前系统日期的年份和周数:
SELECT YEARWEEK(CURDATE());
亲自试一试 »