Data connectivity & integrationPipeline Builder ExpressionsDay of week

Day of week

Supported in: Batch, Faster

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 categories: Datetime

Declared arguments

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

Output type: Integer

Examples

Example 1: Base case

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

Argument values:

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

Example 2: Base case

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

Argument values:

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

Example 3: Base case

Description: Timestamps give the day of the week of their date

Argument values:

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

Output: 1


Example 4: Base case

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

Argument values:

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

Example 5: Null case

Argument values:

  • Expression: date
  • First day of week: null
dateOutput
nullnull