The Date.EndOfMonth function gives you the last day of the month for any date. You’d use it for month-end reporting dates, deadlines that fall at the end of a month, and monthly totals.
The one thing to watch is the time part. If you give it a datetime instead of a date, you get 11:59:59 PM on the last day, and that changes how comparisons work.
In this article, I’ll show you both cases and then the most common ways to use the function.
Follow along with the example file
Date.EndOfMonth Function Examples.xlsx
Date.EndOfMonth Function Syntax
Date.EndOfMonth(dateTime as any) as any
- dateTime – the date, datetime, or datetimezone value you want the end of the month for.
What it returns – the last moment of the month that contains dateTime, as the same type you gave it.
For a date, that’s simply the last day of the month. For a datetime or datetimezone, it’s the last day of the month at 11:59:59.9999999 PM, and a datetimezone keeps its time zone offset.
If dateTime is null, you get null back instead of an error.
When to Use the Date.EndOfMonth Function
Use this function when you need to:
- Get the last day of the month for a date
- Add a month-end date column to a table
- Check whether a date is the last day of its month
- Count the days left in the month, including the start date
- Find the end of the month a few months later, or the end of the previous month
- Keep all the rows up to the end of a month, including the last day’s evening entries
- Total values by month, with the month-end date as the label
- Build a list of month-end dates for a year
Example 1: Get the Last Day of the Month for a Date
Let’s start with the simplest use of the function.
Suppose you have the date April 14, 2026, and you want the last day of that 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.EndOfMonth(#date(2026,4,14))
Result: 4/30/2026

Here, #date(2026,4,14) creates the date April 14, 2026, and Date.EndOfMonth returns April 30, 2026, the last day of April.
The date shows as 4/30/2026 because my computer uses US regional settings. On a computer set to UK settings, the same value shows as 30/04/2026, but it’s still the same date.
You don’t have to know how many days a month has. The function handles 30-day months, 31-day months, and February, including leap years.
For example, a date in February 2028 gives 2/29/2028.
If you want the end of the current month, give the function today’s date instead of a fixed one. Here’s how to get today’s date in Power Query.
Example 2: Use Date.EndOfMonth With a Date and Time
This is where most of the surprises with Date.EndOfMonth come from.
Suppose you have a date and time, April 14, 2026 at 9:30 AM, and you want the end of that month.
Create a new blank query (as in Example 1) and use this formula:
= Date.EndOfMonth(#datetime(2026,4,14,9,30,0))
Result: 2026-04-30T23:59:59.9999999

Here, #datetime(2026,4,14,9,30,0) creates April 14, 2026 at 9:30 AM. Since the input has a time, Date.EndOfMonth returns a datetime too, set to the very last moment of April.
Power Query shows this single value in a year-month-day form with the full time. 23:59:59.9999999 is 11:59:59.9999999 PM on April 30, a fraction of a second before May starts.
So anything that happens on April 30, even at 11:58 PM, still counts as before the end of the month.
Note that this result is not equal to the date 4/30/2026. That matters when you compare dates, which you’ll see in Example 4.
Example 3: Add a Month End Column to a Table
In real data, you’ll usually want the month end for a whole column of dates.
Below is an ExpenseClaims table with the date of each expense claim, and I want the last day of the claim’s month in a new Month End column.

To follow along, select any cell in the ExpenseClaims 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.
If you leave the column as Date/Time, Date.EndOfMonth returns a date and time (11:59:59 PM on the last day, as in Example 2), not a plain date. So click the type icon in the Claim Date header, pick Date, and choose Replace current.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(#"Changed Type","Month End",each Date.EndOfMonth([Claim Date]),type date)
Result: A new Month End column shows 1/31/2026, 2/28/2026, 2/28/2026, 4/30/2026, and 6/30/2026.

Here, the Table.AddColumn function adds the Month End column, and the each keyword runs Date.EndOfMonth on every row. [Claim Date] picks the date from the same row, and type date makes the new column a Date column.
The first argument, #"Changed Type", is the name of the Changed Type step you just set up. So the new column is added to the table as it looks after that step.
Adrian’s claim on 2/3/2026 and Gabriel’s claim on 2/27/2026 both get 2/28/2026, because they’re in the same month. Sarah’s claim is already on the last day of April, so her month end is the same date, 4/30/2026.
Example 4: Check if a Date Is the Last Day of the Month
Here’s another common use case. Some tasks only happen on the last day of the month, like a final meter reading or a month-end stock count.
Below is a MeterReadings table with the date of each meter reading, and I want to check whether each reading was taken on the last day of the month, in a new Is Month End column.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Reading 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","Is Month End",each [Reading Date]=Date.EndOfMonth([Reading Date]),type logical)
Result: A new Is Month End column shows TRUE, FALSE, TRUE, FALSE, TRUE, and FALSE.

Here, the formula compares each reading date with the last day of its own month. If the two are the same, the date is a month end and you get TRUE.
So Carmen’s reading on 3/31/2026 gets TRUE. Catherine’s reading on 5/29/2026 gets FALSE, because May has 31 days.
Important: This check only works when the column has the Date type. On a Date/Time column, 4/30/2026 12:00 AM never equals 4/30/2026 11:59:59 PM, so every row would show FALSE.
Example 5: Count the Days Left in the Month
This next one is useful for anything that’s charged or planned by the day for the rest of a month.
Below is a Members table with the date each gym member joined, and I want the number of days left in their joining month, counting the join day, in a new Days Left column. This is the number you’d use for a part-month (prorated) fee.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Join 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","Days Left",each Duration.Days(Date.EndOfMonth([Join Date])-[Join Date])+1,Int64.Type)
Result: A new Days Left column shows 14, 31, 12, 17, and 1.

Here, Date.EndOfMonth([Join Date])-[Join Date] subtracts the join date from the month end. In Power Query, subtracting two dates gives a duration, and the Duration.Days function turns it into a number of days.
That subtraction doesn’t count the join day itself, so the +1 adds it back. Leah joined on 3/1/2026, so she gets all 31 days of March, and Shelby joined on the last day of April, so she gets 1.
You could also get the same number with Date.DaysInMonth([Join Date])-Date.Day([Join Date])+1. Both work, so use whichever reads more clearly to you.
Follow along with the example file
Date.EndOfMonth Function Examples.xlsx
Example 6: Find the End of the Month a Few Months Later
Date.EndOfMonth works well with the Date.AddMonths function when a deadline falls at the end of a later month.
Below is a NewHires table with the date each employee was hired, and I want their probation end date in a new Probation End column. The probation ends on the last day of the month, three months after the hire date.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Hire 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","Probation End",each Date.EndOfMonth(Date.AddMonths([Hire Date],3)),type date)
Result: A new Probation End column shows 4/30/2026, 5/31/2026, 6/30/2026, 7/31/2026, and 2/28/2027.

Here, the Date.AddMonths function first moves the hire date three months ahead. Then Date.EndOfMonth takes that new date to the last day of its month.
So Grace, hired on 2/10/2026, moves to 5/10/2026 first, and then to 5/31/2026. Alan, hired on 11/3/2026, moves into the next year and gets 2/28/2027.
The order of the two functions matters. If you take the month end first and then add months, you can land a few days short of the month end.
For example, Grace’s 2/28/2026 plus three months gives 5/28/2026, not 5/31/2026. And Olivia’s 4/30/2026 plus three months gives 7/30/2026, not 7/31/2026.
That’s because the Date.AddMonths function keeps the same day number when it can (28 for Grace and 30 for Olivia), even when the later month has more days. So always add the months first and wrap Date.EndOfMonth around the result.
Example 7: Get the End of the Previous Month
Reports often need the last day of the month before, like a statement that shows the balance as of last month end.
Below is a Statements table with the date each account statement was run, and I want the last day of the previous month in a new Balance As Of column.

As in Example 3, load the table with Data > From Table/Range, and make sure the Changed Type step sets the Run 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","Balance As Of",each Date.EndOfMonth(Date.AddMonths([Run Date],-1)),type date)
Result: A new Balance As Of column shows 12/31/2025, 1/31/2026, 2/28/2026, 3/31/2026, and 4/30/2026.

Here, the Date.AddMonths function with -1 moves the run date back one month, and Date.EndOfMonth then gives the last day of that earlier month.
Douglas’s statement run on 1/5/2026 goes back into December, so it gets 12/31/2025. Aaron’s statement on 3/31/2026 moves back to 2/28/2026, which is already the last day of February.
Example 8: Keep All Rows Up to the End of a Month
This is where the 11:59:59 PM time from Example 2 helps you.
Below is a WebOrders table with the date and time each online order was placed, and I want to keep only the orders placed up to the end of April 2026.

As in Example 3, load the table with Data > From Table/Range. This time, keep the Order Time column as Date/Time, because the time of each order matters here.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.SelectRows(#"Changed Type",each [Order Time]<=Date.EndOfMonth(#datetime(2026,4,1,0,0,0)))
Result: Only three rows are left: WO-601 (3/28/2026 10:15:00 AM), WO-602 (4/12/2026 2:30:00 PM), and WO-603 (4/30/2026 11:45:00 PM).

Here, Date.EndOfMonth(#datetime(2026,4,1,0,0,0)) gives the last moment of April 30, 2026 (11:59:59.9999999 PM), and the Table.SelectRows function keeps only the orders placed on or before that moment.
Claire’s order at 11:45 PM on April 30 stays in, because it’s before 11:59:59 PM. Teresa’s order at 12:10 AM on May 1 is dropped.
If you compared with #datetime(2026,4,30,0,0,0) instead, you’d lose every order placed during April 30 itself. Date.EndOfMonth avoids that because it covers the whole last day.
To use a different month, change the date inside Date.EndOfMonth to any date in that month. The function works out the last moment of that month for you.
Another way to write this filter is [Order Time]<#datetime(2026,5,1,0,0,0), which keeps everything before the first moment of May. It gives the same three rows here.
Example 9: Total Values by Month End
Now let’s use the month-end date to add up a table by month.
Below is a Sales table with the date and amount of each sale, and I want the total sales for each month, labeled with the month-end date.

As in Example 3, load the table with Data > From Table/Range. Make sure the Changed Type step sets the Sale Date column to the Date type and the Amount column to Decimal Number.
First, add a month end for each sale. Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.AddColumn(#"Changed Type","Month End",each Date.EndOfMonth([Sale Date]),type date)
Power Query names a step added this way Custom1, so right-click it in the Applied Steps pane, choose Rename, and call it Added Month End. The next formula refers to it by that name.
Next, group the sales by that month end. Add another new step and use this formula:
= Table.Group(#"Added Month End",{"Month End"},{{"Total Sales",each List.Sum([Amount]),type number}})
Result: Three rows: 1/31/2026 with 1005, 2/28/2026 with 705, and 3/31/2026 with 1085.

Here, the first step gives every sale in the same month the same month-end date. The Table.Group function then makes one row for each month-end date, and the List.Sum function adds up the amounts in that group.
So the three January sales (420, 310, and 275) become one row for 1/31/2026 with 1005.
A month-end date works well as a month label because it’s a real date. It sorts in the right order and works with date filters, unlike month names such as “Jan” and “Feb”.
Example 10: Create a List of Month-End Dates
This last example builds the month-end dates for a whole year, which is handy for a reporting calendar.
Suppose you want all twelve month-end dates for 2026.
Create a new blank query (as in Example 1) and use this formula:
= List.Transform({1..12},each Date.EndOfMonth(#date(2026,_,1)))
Result: A list of 12 dates from 1/31/2026 to 12/31/2026.

Here, {1..12} is a list of the month numbers 1 to 12. The List.Transform function runs the formula on each number, where _ stands for the month number being used.
So for each month, #date(2026,_,1) creates the first day of that month, and Date.EndOfMonth turns it into the last day. The list includes 2/28/2026, because 2026 is not a leap year.
To turn the list into a table you can load to a sheet, click To Table on the List Tools Transform tab.
Other Excel Articles You May Also Like:
- Date.EndOfWeek function
- Date.Month function
- Date.AddDays – Use Date.AddDays in Power Query M to add or subtract days from a date.
- Date.MonthName – Use Date.MonthName in Power Query M to get the month name from a date.
- DateTime.LocalNow – Use DateTime.LocalNow in Power Query M to get the current date and time.
- Date.Year – Use Date.Year in Power Query M to extract the year from a date.
- Date.StartOfWeek – Use Date.StartOfWeek in Power Query M to get the first day of a week.
- Date.ToText – Use Date.ToText in Power Query M to convert dates to text.