Date.DayOfWeek

Date

Returns the day of the week for a given date.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Date.DayOfWeek(dateTime as any, optional firstDayOfWeek as nullable number) as nullable number

Parameters

NameTypeRequiredDescription
dateTimeanyYesThe date, datetime, or datetimezone value to find the day of the week for.
firstDayOfWeeknumberNoA Day.Type value indicating the first day of the week. Defaults to Day.Sunday (0). Use Day.Monday (1) for ISO weeks.

Return Value

numberA number from 0 to 6 representing the day of the week.

Remarks

Date.DayOfWeek returns a number from 0 to 6 indicating the day of the week for the given date. By default, 0 represents Sunday and 6 represents Saturday. You can change which day is considered the first day of the week by passing a Day.Type value (e.g., Day.Monday) as the second argument, which shifts the numbering so that the specified day becomes 0. If the input is null, the function returns null.

Examples

Example 1: Find the day of week for each OrderDate

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 5),
        {"OrderID", "OrderDate"}
    ),
    "DayOfWeek", each Date.DayOfWeek([OrderDate], Day.Sunday), Int64.Type
)
Result
OrderID
OrderDate
DayOfWeek
111/15/20241
221/18/20244
332/1/20244
442/10/20246
553/5/20242

Example 2: Use Monday as the first day of the week

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 4),
        {"OrderID", "OrderDate"}
    ),
    "DayOfWeekMon", each Date.DayOfWeek([OrderDate], Day.Monday), Int64.Type
)
Result
OrderID
OrderDate
DayOfWeekMon
111/15/20240
221/18/20243
332/1/20243
442/10/20245

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks