Date.EndOfMonth
DateReturns the last day of the month for a given date.
Syntax
Date.EndOfMonth(dateTime as any) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | The date, datetime, or datetimezone value to find the end of the month for. |
Return Value
any — The last day of the month containing the input date.
Remarks
Date.EndOfMonth returns the last day of the month for the given date, datetime, or datetimezone value. The return type matches the input type. This is useful for calculating month-end reporting periods or payment due dates. If the input is null, the function returns null.
Examples
Example 1: Find the end of each order's month
Table.AddColumn(
Table.SelectColumns(
Table.FirstN(Sales, 5),
{"OrderID", "OrderDate"}
),
"MonthEnd", each Date.EndOfMonth([OrderDate]), type date
)Result
OrderID | OrderDate | MonthEnd | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | 1/31/2024 |
| 2 | 2 | 1/18/2024 | 1/31/2024 |
| 3 | 3 | 2/1/2024 | 2/29/2024 |
| 4 | 4 | 2/10/2024 | 2/29/2024 |
| 5 | 5 | 3/5/2024 | 3/31/2024 |
Example 2: End of month for February in a leap year
#table(
type table [Date = date, EndOfMonth = date],
{{#date(2024, 2, 1), Date.EndOfMonth(#date(2024, 2, 1))}}
)Result
Date | EndOfMonth | |
|---|---|---|
| 1 | 2/1/2024 | 2/29/2024 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks