Date.Day Function in Power Query M

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

The Date.Day function gives you the day of the month from a date, a number from 1 to 31.

You’d use it to add a day column, flag payments made after a cutoff day, split a month into pay periods, or work out how many days are left in a month.

I’ll start with a single date, a date and time, and a date with a time zone. Then we’ll use it on table columns, and finish with dates that arrive as text.

Follow along with the example file

Date.Day Function Examples.xlsx

Download

Date.Day Function Syntax

Date.Day(dateTime as any) as nullable number
  • dateTime – the date, datetime, or datetimezone value you want the day from.

What it returns – the day of dateTime as a whole number from 1 to 31.

If dateTime is null (an empty cell in your data, for example), you get null back instead of an error.

If dateTime is text, like “2026-03-14”, you get an error that says “The Date value must contain the Date component.” You’ll see how to handle text dates in Example 9.

When to Use the Date.Day Function

Use this function when you need to:

  • Get the day of the month from a date, a date and time, or a date with a time zone
  • Add a day number column to a table
  • Mark rows as on time or late based on a cutoff day, like rent due by the 5th
  • Filter rows for part of a month, like the 1st to the 15th
  • Total values by day of the month to spot busy days
  • Count how many days are left in the month from a given date
  • Get the day from dates that came in as day-first text

Example 1: Get the Day From a Date

Let’s start with the simplest use of the function.

Suppose you have the date July 23, 2026, and you want its day of the month.

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.Day(#date(2026,7,23))

Result: 23

Date.Day(#date(2026,7,23)) returns 23

Here, #date(2026,7,23) creates the date July 23, 2026, and Date.Day returns 23 because that’s the day part of the date.

Date.Day gives you the day of the month, not the day of the week. If you want the weekday instead, like Thursday, use the Date.DayOfWeekName function.

And if you need the other parts of the date, the Date.Month and Date.Year functions work the same way.

Example 2: Get the Day From a Date and Time

Date.Day also works when your value has a time part.

Suppose you have a date and time, October 5, 2026 at 11:40 PM, and you want its day of the month.

Create a new blank query (as in Example 1) and use this formula:

= Date.Day(#datetime(2026,10,5,23,40,0))

Result: 5

Date.Day(#datetime(2026,10,5,23,40,0)) returns 5, ignoring the time

Here, #datetime(2026,10,5,23,40,0) creates October 5, 2026 at 11:40 PM, and Date.Day returns 5.

Date.Day ignores the time part, even when it’s this close to midnight. So you don’t need to convert a Date/Time column to a Date column before you use Date.Day on it.

Example 3: Get the Day From a Date With a Time Zone

Timestamps from web apps and online forms often come with a time zone offset. Here’s what Date.Day does with those.

Suppose a form was submitted on March 31, 2026 at 9:00 PM, in a time zone seven hours behind UTC (UTC-07:00), and you want its day of the month.

Create a new blank query (as in Example 1) and use this formula:

= Date.Day(#datetimezone(2026,3,31,21,0,0,-7,0))

Result: 31

Date.Day on a datetimezone value returns 31, the day as written

Here, the last two arguments of #datetimezone, -7 and 0, set the offset to minus seven hours and zero minutes. Date.Day returns 31 because it reads the date as it’s written, March 31.

In UTC, that same moment is already 4:00 AM on April 1. If you need the UTC day, convert the value first with Date.Day(DateTimeZone.ToUtc(...)), which returns 1 here.

Example 4: Add a Day Column to a Table

In real data, you’ll usually want the day for a whole column of dates.

Below is a Deliveries table with the date each order was delivered, and I want the day of the month for each delivery in a new Day column.

Deliveries table with Order, Customer and Delivered On

To follow along, select any cell in the Deliveries table and go to Data > From Table/Range. In the example file, the Changed Type step sets the Delivered 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.AddColumn(#"Changed Type","Day",each Date.Day([Delivered On]),Int64.Type)

Result: A new Day column shows 3, 17, 9, 28, 17, and 30.

New Day column with the day of the month of each delivery

Here, the Table.AddColumn function adds the Day column, and the each keyword runs Date.Day on every row. [Delivered On] picks the date from the same row.

The last argument, Int64.Type, makes the new column a Whole Number column. Without it, the column type shows as ABC123 (any), and you’d have to set the type in a separate step.

Wesley’s order on 1/17/2026 and Isabella’s order on 3/17/2026 both get 17. Date.Day only looks at the day, so the month doesn’t matter.

Example 5: Flag Late Payments After a Cutoff Day

Here’s a common one if you track bills, rent, or subscriptions.

Below is a RentPayments table with the date each tenant paid their rent, and I want a Status column that says “On Time” if the rent was paid by the 5th of the month and “Late” if it wasn’t.

RentPayments table with Tenant, Unit and Paid On

As in Example 4, load the table with Data > From Table/Range.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(#"Changed Type","Status",each if Date.Day([Paid On]) <= 5 then "On Time" else "Late",type text)

Result: A new Status column shows On Time, Late, On Time, Late, On Time, and Late.

New Status column: On Time if paid by the 5th, otherwise Late

Here, Date.Day gets the day each tenant paid, and the if…then…else checks whether it’s 5 or less. Martha paid on 2/5/2026, which is exactly on the cutoff, so she gets On Time.

Tracy paid just one day later, on 2/6/2026, so she gets Late. To use a different cutoff, change the 5 in the formula to your own due day.

This check assumes each payment falls in the month it’s due. A January payment made early, on December 30, would show as Late because its day is 30.

Follow along with the example file

Date.Day Function Examples.xlsx

Download

Example 6: Filter Rows for the First Half of the Month

Lots of companies pay people twice a month, once for the 1st to the 15th and once for the rest of the month. Here’s how to pull out the first pay period.

Below is a Timesheet table with the hours each employee worked on a day in March, and I want to keep only the rows from the 1st to the 15th.

Timesheet table with Employee, Work Date and Hours for March

As in Example 4, load the table with Data > From Table/Range.

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.Day([Work Date]) <= 15)

Result: Four rows remain: Zoe (3/2/2026), Allison (3/6/2026), Miranda (3/13/2026), and Erin (3/15/2026).

Only the four rows from the 1st to the 15th remain

Here, the Table.SelectRows function keeps only the rows where the condition is true. Erin’s row on 3/15/2026 stays because 15 is included, and Eric’s row on 3/16/2026 is the first one that drops out.

For the second pay period, change <= 15 to > 15. You’ll get the rows from the 16th to the end of the month, whether the month has 28, 30, or 31 days.

Example 7: Total Values by Day of the Month

This next one helps you spot which days of the month are busiest.

Below is a Donations table with the date and amount of each donation over three months, and I want the total amount for each day of the month, sorted by day.

Donations table with Donation, Received On and Amount

As in Example 4, load the table with Data > From Table/Range. In the example file, the Changed Type step sets Received On to Date and Amount to Decimal Number.

This one takes three steps. Add each as a new step (by clicking on the fx icon next to the formula bar), one after the other.

Each formula starts from the step before it by name.

So rename each new step before you type the next formula, by right-clicking it in Applied Steps and choosing Rename. Name the first one Added Day and the second Grouped Rows.

= Table.AddColumn(#"Changed Type","Day",each Date.Day([Received On]),Int64.Type)
= Table.Group(#"Added Day",{"Day"},{{"Total Amount",each List.Sum([Amount]),type number}})
= Table.Sort(#"Grouped Rows",{{"Day",Order.Ascending}})

Result: Three rows, one per day: 1 (840), 15 (355), and 28 (135).

Total amount for each day of the month, sorted by day

Here, the first step adds a Day column, as in Example 4. The Table.Group function then groups the rows by that column and adds up the Amount values for each day.

For example, the three donations on the 1st (250, 310, and 280) add up to 840, even though they came in different months. The last step sorts the result so the 1st comes first.

In this data, most of the money comes in on the 1st of the month, which is handy to know when you plan donation reminders.

Example 8: Count the Days Left in the Month

Here’s a slightly more advanced one. When a subscription starts partway through a month, you often need to know how many days of that month to bill.

Below is a Subscriptions table with the start date of each customer’s plan, and I want the number of days to bill in the first month, counting the start day, in a new Days Billed column.

Subscriptions table with Customer, Plan and Start Date

As in Example 4, load the table with Data > From Table/Range.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(#"Changed Type","Days Billed",each Date.DaysInMonth([Start Date]) - Date.Day([Start Date]) + 1,Int64.Type)

Result: A new Days Billed column shows 12, 19, 1, 30, and 15.

New Days Billed column counting the start day to month end

Here, the Date.DaysInMonth function gives the number of days in the start month, and Date.Day gives the start day. Subtracting one from the other gives the days after the start day, and the + 1 adds the start day itself.

Jocelyn started on 2/10/2026. February 2026 has 28 days, so she’s billed for 28 – 10 + 1 = 19 days.

Brittany started on 4/30/2026, the last day of April, so she’s billed for just 1 day. Carl started on 6/1/2026 and gets the full 30 days of June.

If you don’t want to count the start day, remove the + 1 from the formula.

Example 9: Get the Day From Day-First Text Dates

This last one covers a problem you’ll hit when you import data from another country.

Below is a Bookings table exported from a French booking system, with arrival dates stored as text in day-first format (day/month/year), and I want the day of the month for each booking in a new Day column.

Bookings table with day-first text dates in the Arrival Date column

If you run Date.Day on this column straight away, every row gives an error, “The Date value must contain the Date component.” That’s because the values are text, not dates.

A plain type change to Date doesn’t fix it on a US computer either. “11/03/2026” quietly becomes November 3, so Date.Day returns 3 instead of 11, and “23/05/2026” gives the error “We couldn’t parse the input provided as a Date value.”

The November 3 one is worse than an error, because Date.Day still gives you a day number that looks fine. So the mistake is easy to miss.

The fix is to tell Power Query to read the text as day, then month, then year, before Date.Day runs.

First, load the table with Data > From Table/Range, as in Example 4. Then delete the automatic Changed Type step (click the X next to it in the Applied Steps pane), because it treats the dates as plain text.

Now change the column type using the right locale. In the Power Query editor, right-click the Arrival Date header, go to Change Type > Using Locale, pick Date as the data type and French (France) as the locale, and click OK.

That creates a step with this formula. If the new step has a different name, right-click it and rename it to Changed Type, because the next formula refers to it by that name.

= Table.TransformColumnTypes(Source,{{"Arrival Date",type date}},"fr-FR")

The “fr-FR” at the end tells Power Query to read the text as day, then month, then year. So “11/03/2026” becomes March 11, 2026, not November 3.

Now add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.AddColumn(#"Changed Type","Day",each Date.Day([Arrival Date]),Int64.Type)

Result: The Arrival Date column now shows real dates, and a new Day column shows 4, 11, 23, 6, and 30.

Arrival Date converted to real dates and a new Day column

Here, Date.Day works because the Changed Type step already turned the text into dates. The second booking, arriving on 3/11/2026 (March 11), gets 11, and the third one, on 5/23/2026, gets 23.

The dates show as 3/11/2026 because my computer uses US regional settings. On a computer set to UK settings, the same date shows as 11/03/2026, but the day is still 11.

Other Excel Articles You May Also Like:

  • Date.DayOfWeek – Use Date.DayOfWeek in Power Query M to get the day number of a date.
  • Date.EndOfMonth – Use Date.EndOfMonth in Power Query M to get the last day of a month.
  • Date.StartOfMonth – Use Date.StartOfMonth in Power Query M to get the first day of the month.
  • Date.AddDays – Use Date.AddDays in Power Query M to add or subtract days from a date.
  • Duration.Days – Use Duration.Days in Power Query M to extract the day component from a duration value.
  • Date.AddMonths – Use Date.AddMonths in Power Query M to add or subtract months.
  • Date.From – Use Date.From in Power Query M to turn a datetime, serial number, or text into a clean date value.
  • DateTime.LocalNow – Use DateTime.LocalNow in Power Query M to get the current date and time.

All Power Query Functions

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.