Date.DayOfWeek

Updated on

Date.DayOfWeek is a function in the Power Query M language that returns a number from 0 to 6 indicating the day of the week of the provided value. The function accepts a parameter to specify which day should be considered the first day of the week.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Date.DayOfWeek(
   dateTime as any,
   optional firstDayOfWeek as nullable number,
) as nullable number
ArgumentAttributeDescription
dateTimeA date, datetime or datetimezone value.
firstDayOfWeekoptionalThe Day.Type specifies the starting day of the week. If not explicitly specified, the function defaults to a culture-dependent day, aligning with regional week-start norms. It accepts values representing each day:
Day.Sunday (0) for Sunday,
Day.Monday (1) for Monday,
Day.Tuesday (2) for Tuesday,
Day.Wednesday (3) for Wednesday,
Day.Thursday (4) for Thursday,
Day.Friday (5) for Friday,
Day.Saturday (6) for Saturday.

Description

Date.DayOfWeek returns a number from 0 to 6 indicating the day of the week for a provided date, datetime, or datetimezone value (dateTime). An optional parameter (firstDayOfWeek) can be used to specify the first day of the week.

Examples

Get the day of the week represented by Monday, February 21st, 2011, treating Sunday as the first day of the week.

// Output: 1
Date.DayOfWeek( #date( 2011, 02, 21 ), Day.Sunday )

Get the day of the week represented by Monday, February 21st, 2011, treating Monday as the first day of the week.

// Output: 0
Date.DayOfWeek( #date( 2011, 02, 21 ), Day.Monday )

Learn more about Date.DayOfWeek in the following articles:

Other functions related to Date.DayOfWeek are:

BI Gorilla Blog

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/date-dayofweek