📜  MySQL Week()函数

📅  最后修改于: 2020-11-20 06:47:37             🧑  作者: Mango

MySQL Date / Time week()函数

week()是MySQL的日期/时间函数。它用于获取给定日期的星期部分。

句法

select week(date_value, [mode]);

参数:

Date_value:获取星期的日期

模式:它是可选的。它用于指定星期几。可以是以下之一:

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

返回值:

此函数返回日期值的星期部分。

例子1

select week('2018-10-03');

输出:

例子2

select week('1995-02-11');

输出: