WEEKDAY
- WEEKDAY(date, return_type=None)[source]
Returns the day of the week for a given date, using a customizable numbering scheme.
This function calculates the weekday for each date in date or a single date. The numbering of the days is determined by return_type, following conventions similar to Excel’s WEEKDAY function.
- Parameters:
date (
Operand) –The date or date array to evaluate.
Supported types:
DATE
DATE_ARRAY
return_type (
Operand|int|None) –Optional parameter specifying the day numbering scheme. Can be a scalar integer (1-3 or 11-17) or a numeric model object. Defaults to 1 (Sunday=1 through Saturday=7).
Supported types:
INTEGER
INTEGER_ARRAY
- Return type:
- Returns:
A formula representing the weekday(s).
Supported types:
INTEGER
INTEGER_ARRAY
- Raises:
ValueError – If date is not DATE or DATE_ARRAY, or if return_type is outside the allowed range or of invalid type and is determinable at compile time.
Examples
Default numbering (Sunday=1 through Saturday=7):
WEEKDAY(DATE("2025-09-03")) # Returns 4 (Wednesday)
Monday=1 through Sunday=7:
WEEKDAY(DATE("2025-09-03"), 2) # Returns 3 (Wednesday)
Monday=0 through Sunday=6:
WEEKDAY(DATE("2025-09-03"), 3) # Returns 2 (Wednesday)
Note
The return type follows the same format as Excel’s WEEKDAY function. For details see: <https://support.microsoft.com/en-us/office/ weekday-function-60e44483-2ed1-439f-8bd0-e404c190949a>