Date.EndOfMonth
Date function · By Tahir Nas · Examples run in our simulator · Published · Updated
Returns the last day of the month.
When to use it
Use it for month-end reporting dates, period keys and due dates that fall on the last day of a month. It handles month lengths and leap years for you.
Syntax
Date.EndOfMonth(dateTime as any) as anyReturns
A date on the last day of the month.
Example
Date.Day(Date.EndOfMonth(#date(2028, 2, 10)))Result
29
Example: month-end key for every row
Grouping by the month-end date gives one key per month.
Date.ToText(Date.EndOfMonth(#date(2026, 4, 9)), "yyyy-MM-dd")Result
2026-04-30
Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.
Good to know
- Handles month lengths and leap years.
Common mistakes
- Building month ends with day 30 or 31 by hand.
- Applying it to text dates before converting them.
Exercises that use Date.EndOfMonth
Learn more
- Date parts and durations lesson
- Build a date table in Power Query guide
- Power Query date functions cheat sheet (tested) guide
Related functions
Official documentation: Date.EndOfMonth on Microsoft Learn.