Date.EndOfQuarter

Date

Returns the last moment of the quarter containing the given date.

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

Syntax

Date.EndOfQuarter(dateTime as any) as any

Parameters

NameTypeRequiredDescription
dateTimeanyYesA date, datetime, or datetimezone value.

Return Value

anyA datetime or datetimezone value representing the last instant of the quarter.

Remarks

Date.EndOfQuarter returns the last instant (23:59:59.9999999) of the calendar quarter containing the given date, datetime, or datetimezone value. Calendar quarters are Q1 (Jan–Mar), Q2 (Apr–Jun), Q3 (Jul–Sep), and Q4 (Oct–Dec). When given a plain date, the result is a datetime. The return type matches the input type for datetime and datetimezone.

This function is commonly used in quarter-to-date range filters. Pair it with Date.StartOfQuarter to define an inclusive window: [OrderDate] >= Date.StartOfQuarter(today) and [OrderDate] <= Date.EndOfQuarter(today). For just the date portion of the quarter end (without time), wrap the result in DateTime.Date(Date.EndOfQuarter(d)) or use Date.EndOfMonth on the last month of the quarter.

Note that Date.EndOfQuarter always returns a datetime (not a date) even when passed a plain date, because the quarter end is a specific instant in time with a time component. If downstream logic requires a date, explicitly cast the result.

Examples

Example 1: Add quarter-end date to each order

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 5),
        {"OrderID", "OrderDate"}
    ),
    "QuarterEnd", each Date.EndOfQuarter([OrderDate]), type datetime
)
Result
OrderID
OrderDate
QuarterEnd
111/15/20243/31/2024 11:59:59 PM
221/18/20243/31/2024 11:59:59 PM
332/1/20243/31/2024 11:59:59 PM
442/10/20243/31/2024 11:59:59 PM
553/5/20243/31/2024 11:59:59 PM

Example 2: Return quarter-end dates for each quarter

#table(
    type table [Quarter = text, EndDate = datetime],
    {
        {"Q1", Date.EndOfQuarter(#date(2024, 1, 1))},
        {"Q2", Date.EndOfQuarter(#date(2024, 4, 1))},
        {"Q3", Date.EndOfQuarter(#date(2024, 7, 1))},
        {"Q4", Date.EndOfQuarter(#date(2024, 10, 1))}
    }
)
Result
Quarter
EndDate
1Q13/31/2024 11:59:59 PM
2Q26/30/2024 11:59:59 PM
3Q39/30/2024 11:59:59 PM
4Q412/31/2024 11:59:59 PM

Example 3: Filter to current quarter-to-date orders

let
    QuarterStart = Date.StartOfQuarter(Date.From(DateTime.LocalNow())),
    QuarterEnd = Date.EndOfQuarter(Date.From(DateTime.LocalNow()))
in
    Table.SelectRows(
        Sales,
        each [OrderDate] >= QuarterStart and DateTime.From([OrderDate]) <= QuarterEnd
    )
Applied Steps

The final output — filters the Sales table to rows where OrderDate falls within the current quarter.

OrderID
CustomerName
Product
Category
UnitPrice
Quantity
OrderDate
Region
17CharlieGadget BGadgets5034/1/2024West
28DianaWidget CWidgets1584/15/2024North

Compatibility

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