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>
optionalFirst 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
date
Output
2024-01-08
1
2024-01-13
6
2024-01-07
7
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
date
Output
2024-01-07
1
2024-01-08
2
2024-01-13
7
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