メインコンテンツまでスキップ
バージョン: 2.1

week

説明

構文

INT WEEK(DATE date[, INT mode])

dateの週番号を返します。mode引数の値のデフォルトは0です。 以下の表は、mode引数がどのように動作するかを説明しています。

Mode週の最初の曜日範囲週1は最初の週…
0Sunday0-53with a Sunday in this year
1Monday0-53with 4 or more days this year
2Sunday1-53with a Sunday in this year
3Monday1-53with 4 or more days this year
4Sunday0-53with 4 or more days this year
5Monday0-53with a Monday in this year
6Sunday1-53with 4 or more days this year
7Monday1-53with a Monday in this year

パラメータはDateまたはDatetime型です

mysql> select week('2020-1-1');
+------------------+
| week('2020-1-1') |
+------------------+
| 0 |
+------------------+
mysql> select week('2020-7-1',1);
+---------------------+
| week('2020-7-1', 1) |
+---------------------+
| 27 |
+---------------------+

keywords

WEEK
このページでは