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:

Formula

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