Date.EndOfQuarter
DateReturns the last moment of the quarter containing the given date.
Syntax
Date.EndOfQuarter(dateTime as any) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A date, datetime, or datetimezone value. |
Return Value
any — A 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
)OrderID | OrderDate | QuarterEnd | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | 3/31/2024 11:59:59 PM |
| 2 | 2 | 1/18/2024 | 3/31/2024 11:59:59 PM |
| 3 | 3 | 2/1/2024 | 3/31/2024 11:59:59 PM |
| 4 | 4 | 2/10/2024 | 3/31/2024 11:59:59 PM |
| 5 | 5 | 3/5/2024 | 3/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))}
}
)Quarter | EndDate | |
|---|---|---|
| 1 | Q1 | 3/31/2024 11:59:59 PM |
| 2 | Q2 | 6/30/2024 11:59:59 PM |
| 3 | Q3 | 9/30/2024 11:59:59 PM |
| 4 | Q4 | 12/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
)The final output — filters the Sales table to rows where OrderDate falls within the current quarter.
OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region | |
|---|---|---|---|---|---|---|---|---|
| 1 | 7 | Charlie | Gadget B | Gadgets | 50 | 3 | 4/1/2024 | West |
| 2 | 8 | Diana | Widget C | Widgets | 15 | 8 | 4/15/2024 | North |