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
| Argument | Attribute | Description |
|---|---|---|
| dateTime | A date, datetime or datetimezone value. | |
| firstDayOfWeek | optional | The 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
The Date.DayOfWeek function works with date, datetime, and datetimezone values.
Extracting the Day of the Week for a Date Value
When you apply the Date.DayOfWeek function to a date value, it returns the day of the week as a number. By default, the start of the week is considered to be Monday, which is represented as 0. Here’s an example:
// Output: 5 (Saturday)
Date.DayOfWeek( #date( 2024, 6, 15 ) )
This expression returns 5, as June 15, 2024 falls on a Saturday.
For a clear image, here’s a table with 7 consecutive dates. You can extract the day of the week for each date by using Date.DayOfWeek.

Using the Day.Type Parameter
If you want the start of the week to fall on a different day, you can make use of the Day.Type enumeration. Simply specify your desired start of the week in the second argument of Date.DayOfWeek.
For instance, if you consider Wednesday as the first day of the week, the Date.DayOfWeek function will return 3 for Saturday:
// Output: 3
Date.DayOfWeek( #date( 2024, 6, 15 ), Day.Wednesday)
Here’s what that looks like for a range of dates:

You can find the start of the week value specified in the second argument. As you can see, Wednesday now has a week day number 0.
Extracting the Day of the Week for a DateTime Value
The function also supports datetime values. To find the day of the week for a datetime value of June 15, 2024, 12:00 AM:
// Output: 5 (Saturday)
Date.DayOfWeek( #datetime( 2024, 6, 15, 0, 0, 0 ) )
This expression returns 5, as June 15, 2024 falls on a Saturday.
Extracting the Day of the Week for a DateTimeZone Value
Similarly, applying the function to a datetimezone value returns the day of the week for that datetimezone:
// Output: 0 (Monday)
Date.DayOfWeek( #datetimezone( 2024, 7, 15, 0, 0, 0, 1, 0 ) )
This expression returns 0, as July 15, 2024 falls on a Monday and is the default start of the week date.
Related articles
Learn more about Date.DayOfWeek in the following articles:
- Create ISO Week and ISO Year in Power Query M (ISO 8601)
Learn how to create ISO Week and Year numbers in Power Query for consistent weeks and fiscal calendars. Step-by-step tutorial included! » Read more - Return Next Working Day in Power Query
Do you want to return the next working day in Power Query? There is no build in M-function for this, but this post shows how to create one yourself! » Read more - Create Date Table or Calendar in Power Query M
Learn how to create a dynamic calendar table in Power Query’s M language. Build your custom columns and claim your free Date Table Script. » Read more
Related functions
Other functions related to Date.DayOfWeek are:
- Date.Day
- Date.DayOfYear
- Date.DaysInMonth
- Date.Month
- Date.QuarterOfYear
- Date.WeekOfMonth
- Date.WeekOfYear
- Date.Year
2023-2026 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy