Day of week

サポート対象:バッチ、高速

Returns the day of the week of a date or timestamp as a number from 1 to 7, where the first day of the week is 1.

式のカテゴリー: 日時

引数

  • Expression: Date or timestamp to get the day of the week of.
    Expression<Date | Timestamp>
  • 任意 First day of week: Day that counts as 1. Defaults to Monday, as in ISO 8601.
    Enum<Friday, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday>

出力タイプ: Integer

例

例1:基本ケース

説明: Weeks start on Monday by default, so Monday is 1 and Sunday is 7

引数の値:

  • Expression: date
  • First day of week: null
date出力
2024-01-081
2024-01-136
2024-01-077

例2:基本ケース

説明: Weeks that start on Sunday count Sunday as 1 and Saturday as 7

引数の値:

  • Expression: date
  • First day of week: SUNDAY
date出力
2024-01-071
2024-01-082
2024-01-137

例3:基本ケース

説明: Timestamps give the day of the week of their date

引数の値:

  • Expression: 2024-01-07T10:00:00Z
  • First day of week: SUNDAY

出力: 1


例4:基本ケース

説明: Weeks can start on any day, which then counts as 1

引数の値:

  • Expression: date
  • First day of week: WEDNESDAY
date出力
2024-01-101
2024-01-075
2024-01-097

例5:Null ケース

引数の値:

  • Expression: date
  • First day of week: null
date出力
nullnull