Date.EndOfMonth
The last day of the month a date falls in.
Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Date.EndOfMonth(dateTime as any) as any
| Parameter | Type | Description |
|---|---|---|
dateTime | any | A date, datetime or datetimezone value; null gives null. |
Returns
any. The same kind of value, on the month's last day.
Remarks
- For a datetime or datetimezone the answer is the last moment of that day, 23:59:59.9999999; for a date it is the date.
- Leap years are taken into account.
Examples
Month end for an invoice
Date.EndOfMonth(#date(2024, 2, 10))
#date(2024, 2, 29)
Invoice due on the last day of next month
Date.EndOfMonth(Date.AddMonths(#date(2024, 1, 31), 1))
#date(2024, 2, 29)
A datetime ends at the day's last moment
Date.EndOfMonth(#datetime(2024, 4, 3, 9, 0, 0))
#datetime(2024, 4, 30, 23, 59, 59.9999999)
Related functions
Date.StartOfMonth, Date.DaysInMonth, Date.EndOfQuarter, Date.AddMonths.