The Date.DayOfWeek function tells you which day of the week a date falls on, as a number from 0 to 6. So instead of “Monday”, you get a number you can compare, filter, and calculate with.
The one thing to watch is which day counts as 0, because that depends on how you call the function. In this article, I’ll show you how to control that, and then use the day number to flag weekends, count working days, and more.
Follow along with the example file
Date.DayOfWeek Function Examples.xlsx
Date.DayOfWeek Function Syntax
Date.DayOfWeek(dateTime as any, optional firstDayOfWeek as nullable number) as nullable number
- dateTime – the date, datetime, or datetimezone value you want the day of the week for.
- firstDayOfWeek (optional) – the day that should count as the first day of the week, which gets the number 0. Use one of Day.Sunday, Day.Monday, Day.Tuesday, Day.Wednesday, Day.Thursday, Day.Friday, or Day.Saturday. These are just the numbers 0 (Day.Sunday) to 6 (Day.Saturday). If you leave it out, Power Query uses a default that depends on your computer’s culture setting.
What it returns – a whole number from 0 to 6. 0 is the first day of the week, 1 is the second day, and so on.
If dateTime is null, you get null back instead of an error.
When to Use the Date.DayOfWeek Function
Use this function when you need to:
- Get the day of the week of a date as a number
- Number the days of the week from Monday instead of Sunday, or from 1 to 7
- Mark each row as a weekday or a weekend
- Keep only the rows that fall on a weekend (or only on weekdays)
- Count the working days between two dates
- Move a date to a set day of the week, like a Friday pay date with a cutoff day
- Count rows by day of the week and show the days in the right order
Example 1: Get the Day Number of a Date
Let’s start with the simplest use of the function.
Suppose you have the date March 16, 2026, which is a Monday, and you want its day of the week as a number.
Create a new blank query (in Excel, go to Data > Get Data > From Other Sources > Blank Query) and type this formula in the formula bar:
= Date.DayOfWeek(#date(2026,3,16))
Result: 1

Here, #date(2026,3,16) creates the date March 16, 2026, and Date.DayOfWeek returns 1 for it. That’s because I didn’t tell the function which day starts the week, so it used the default for my computer’s culture setting.
My computer is set to English (United States), where the week starts on Sunday. So Sunday is 0, Monday is 1, and Saturday is 6.
On a computer with a different culture setting, the default first day can be different, so the same formula could return a different number. That’s why I recommend always giving the function the second argument, which is what the next example does.
Example 2: Make Monday the First Day of the Week
This is where most of the confusion with Date.DayOfWeek comes from. People expect Monday to be the first day of the week (0), but the default on a US computer gives 1, because Sunday comes first.
Suppose you want the day of the week of the same date, March 16, 2026, but with Monday counted as the first day of the week.
Create a new blank query (as in Example 1) and use this formula:
= Date.DayOfWeek(#date(2026,3,16),Day.Monday)
Result: 0

Here, Day.Monday tells the function that the week starts on Monday. So Monday is now 0, Tuesday is 1, and so on, up to Sunday, which is 6.
It’s the same date as in Example 1, but the result changed from 1 to 0, only because the first day of the week changed. Since the argument is in the formula, you get 0 on any computer.
Example 3: Add a Day Number Column to a Table
In real data, you’ll usually want the day of the week for a whole column of dates.
Below is a Bookings table with the date of each fitness class a member booked, and I want the day of the week as a number in a new Day Number column.

To follow along, select any cell in the Bookings table and go to Data > From Table/Range. Power Query adds a Changed Type step, and Excel dates usually come in there with the Date/Time type.
These dates have no time, so click the type icon in the Class Date header, pick Date, and choose Replace current.
Date.DayOfWeek works on Date/Time values too, so this step just keeps the column clean. If the dates come in as text instead, the function gives the error “We expected a Date value with a Days part.”
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(#"Changed Type","Day Number",each Date.DayOfWeek([Class Date],Day.Monday),Int64.Type)
Result: A new Day Number column shows 0, 3, 5, 6, and 2.

Here, the Table.AddColumn function adds the Day Number column, and the each keyword runs Date.DayOfWeek on every row. [Class Date] picks the date from the same row, and Int64.Type makes the new column a Whole Number column.
Since the formula uses Day.Monday, Monday is 0. So Mario’s class on 3/2/2026 (a Monday) gets 0, and Sierra’s class on 3/8/2026 (a Sunday) gets 6.
Example 4: Number the Days From 1 to 7
Date.DayOfWeek always starts counting from 0. But a lot of reports number the days from 1 to 7, with Monday as 1 and Sunday as 7.
Below is a Deliveries table with the date each order was delivered, and I want the day of the week as a number from 1 to 7 in a new Day Number column.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Delivery Date column to the Date type.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(#"Changed Type","Day Number",each Date.DayOfWeek([Delivery Date],Day.Monday)+1,Int64.Type)
Result: A new Day Number column shows 1, 4, 6, 7, and 2.

Here, Date.DayOfWeek with Day.Monday gives 0 for Monday and 6 for Sunday, and the +1 moves every number up by one. So Ryan’s delivery on Monday, 3/9/2026 gets 1, and Carmen’s delivery on Sunday, 3/15/2026 gets 7.
This matches what the WEEKDAY function in Excel gives with 2 as its second argument, so both sides of a report can use the same numbers.
You might try to get 1 to 7 by passing a number like 7 as the second argument instead. That doesn’t work, because the second argument only accepts the numbers 0 to 6 (the 7 Day values).
So with 7, you get the error “The Day value provided is invalid.”
Example 5: Flag Weekend Dates
This next one comes up a lot with timesheets and shift data.
Below is a Timesheet table with the date each employee worked and their hours, and I want to mark each row as Weekday or Weekend in a new Day Type column.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Work Date column to the Date type.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(#"Changed Type","Day Type",each if Date.DayOfWeek([Work Date],Day.Monday)>=5 then "Weekend" else "Weekday",type text)
Result: A new Day Type column shows Weekday, Weekend, Weekend, Weekday, Weekday, and Weekend.

Here, with Monday as the first day, Saturday is 5 and Sunday is 6. So the check >=5 is true only for Saturdays and Sundays, and those rows get “Weekend”.
This is why Day.Monday is so handy for weekend checks. The weekend ends up as the last two numbers, so one comparison covers both days.
If you use Day.Sunday instead, Sunday is 0 and Saturday is 6, so you’d need two checks, one for 0 and one for 6.
Follow along with the example file
Date.DayOfWeek Function Examples.xlsx
Example 6: Keep Only the Weekend Rows
You can also use Date.DayOfWeek inside a filter, so you only keep the rows you need.
Below is a Tickets table with the date each support ticket was opened, and I want to keep only the tickets opened on a Saturday or Sunday.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Opened On column to the Date type.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.SelectRows(#"Changed Type",each Date.DayOfWeek([Opened On],Day.Monday)>=5)
Result: Only four rows are left: TK-302 (3/7/2026), TK-304 (3/14/2026), TK-305 (3/15/2026), and TK-308 (3/22/2026).

Here, the Table.SelectRows function keeps only the rows where the condition is true. It’s the same >=5 check as in Example 5, so only the Saturday and Sunday tickets stay.
To keep only the weekday rows instead, change >=5 to <5. That keeps Monday (0) through Friday (4).
Example 7: Count Working Days Between Two Dates
Now let’s use Date.DayOfWeek to count the working days (Monday to Friday) between two dates.
Below is a Tasks table with the start date and end date of each task, and I want the number of working days for each task in a new Working Days column.

As in Example 3, load the table with Data > From Table/Range. This time, make sure the Changed Type step sets both the Start Date and End Date columns to the Date type.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(#"Changed Type","Working Days",each
List.Count(List.Select(
List.Dates([Start Date],Duration.Days([End Date]-[Start Date])+1,#duration(1,0,0,0)),
each Date.DayOfWeek(_,Day.Monday)<5)),Int64.Type)
Result: A new Working Days column shows 5, 5, 2, 0, and 15.

Here, the formula works from the inside out. [End Date]-[Start Date] gives the gap between the two dates, and the Duration.Days function turns that gap into a number of days.
That number tells the List.Dates function how many dates to create, one day apart, starting from the start date. The +1 is needed because subtracting the dates leaves out one end, so without it the end date wouldn’t be in the list.
The List.Select function keeps only the dates where Date.DayOfWeek is below 5, which means Monday to Friday.
Inside that List.Select condition, _ stands for the date being checked. Then the List.Count function counts the dates that are left.
So the Price list task, from Friday, 3/6/2026 to Monday, 3/9/2026, covers 4 days, but only Friday and Monday are working days, which gives 2. The Stock check task runs only over a weekend, so it gets 0.
Make sure the end date isn’t before the start date, or the row can show the error “The ‘count’ argument is out of range.” A blank end date gives the error “We cannot convert the value null to type Number.”
Public holidays still count as working days here. If you need to skip them too, you’d need a list of holiday dates to remove.
Example 8: Find the Friday Pay Date With a Cutoff Day
Date.DayOfWeek also helps when a date has to jump to a specific day of the week, based on a rule.
Below is an Invoices table with the date each freelancer sent an invoice, and I want the pay date in a new Pay Date column. Invoices that arrive by Wednesday get paid that Friday, and anything from Thursday on waits for the next Friday.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Invoice Date column to the Date type.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(#"Changed Type","Pay Date",each Date.AddDays([Invoice Date],8-Date.DayOfWeek([Invoice Date],Day.Thursday)),type date)
Result: A new Pay Date column shows 3/6/2026, 3/6/2026, 3/13/2026, 3/13/2026, and 3/13/2026.

Here, the trick is Day.Thursday. With Thursday as the first day of the week, Thursday is 0 and Wednesday is 6, so the cutoff day is the last day of this week.
The 8 is 6 plus 2. Taking the day number away from 6 gets you to the Wednesday cutoff, and 2 more days get you to that week’s Friday.
The Date.AddDays function then adds that many days to the invoice date.
Elizabeth’s invoice on Monday, 3/2/2026 has a day number of 4, so it adds 4 days and gets paid on Friday, 3/6/2026. Deborah’s invoice on Wednesday, 3/4/2026 has a day number of 6, so it adds 2 days and is paid the same Friday.
Kylie’s invoice on Thursday, 3/5/2026 has a day number of 0, so it adds 8 days and moves to the next Friday, 3/13/2026. Brenda’s Friday invoice and Bradley’s Sunday invoice land on 3/13/2026 too.
Example 9: Count Rows by Day of the Week in Order
This last example finds the busiest day of the week by counting the orders on each day.
Below is an Orders table with the date of each order, and I want the number of orders for each day of the week, listed from Monday to Sunday.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Order Date column to the Date type.
First, add a day number for each order. Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(#"Changed Type","Day Number",each Date.DayOfWeek([Order Date],Day.Monday),Int64.Type)
Power Query names a step added this way Custom1, so right-click it in the Applied Steps pane, choose Rename, and call it Added Day Number. The next formula refers to it by that name.
Next, group the orders by that day number. Add another new step, rename it Grouped Rows the same way, and use this formula:
= Table.Group(#"Added Day Number",{"Day Number"},{
{"Day",each Date.DayOfWeekName(List.First([Order Date])),type text},
{"Orders",each Table.RowCount(_),Int64.Type}})
Finally, sort the result by the day number. Add one more new step and use this formula:
= Table.Sort(#"Grouped Rows",{{"Day Number",Order.Ascending}})
Result: Seven rows from Monday to Sunday, with 2, 1, 1, 1, 1, 4, and 2 orders.

Here, the first step adds a Day Number column, with Monday as 0 and Sunday as 6. The Table.Group function then makes one row for each day number.
In the Group step, the Date.DayOfWeekName function gets the day name from the first order in each group, and the Table.RowCount function counts the orders. So Saturday shows 4 orders, the most of any day.
The last step is why the day number matters.
If you sorted by the day name, you’d get Friday, Monday, Saturday, and so on in alphabetical order. Sorting by the number puts the days in the right order, from Monday to Sunday.
Note that a day with no orders at all won’t show up in the result, because Table.Group only makes rows for the day numbers it finds. Also, the day names come out in the language of your computer’s culture setting.
Other Excel Articles You May Also Like:
- Date.EndOfWeek
- Date.StartOfWeek
- Date.WeekOfYear
- Date.Month – Use Date.Month in Power Query M to get the month number from a date.
- Date.EndOfMonth – Use Date.EndOfMonth in Power Query M to get the last day of a month.
- Date.ToText – Use Date.ToText in Power Query M to convert dates to text.
- Date.Year – Use Date.Year in Power Query M to extract the year from a date.
- DateTime.LocalNow – Use DateTime.LocalNow in Power Query M to get the current date and time.