Date.EndOfMonth

Date

Returns the last day of the month for a given date.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Date.EndOfMonth(dateTime as any) as any

Parameters

NameTypeRequiredDescription
dateTimeanyYesThe date, datetime, or datetimezone value to find the end of the month for.

Return Value

anyThe 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
111/15/20241/31/2024
221/18/20241/31/2024
332/1/20242/29/2024
442/10/20242/29/2024
553/5/20243/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
12/1/20242/29/2024

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks