Time.EndOfHour

Time

Returns the last moment of the hour for the given time or datetime value.

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

Syntax

Time.EndOfHour(dateTime as any) as any

Parameters

NameTypeRequiredDescription
dateTimeanyYesA time, datetime, or datetimezone value.

Return Value

anyA time, datetime, or datetimezone value representing XX:59:59.9999999.

Remarks

Time.EndOfHour returns the very last instant of the clock hour containing the input value: XX:59:59.9999999. When passed a plain time, it returns a time. When passed a datetime or datetimezone, it returns the same type with only the time component adjusted to the end of the hour — the date and any timezone offset are preserved unchanged.

Pair Time.EndOfHour with Time.StartOfHour using the same input to build inclusive hourly range filters. For example: [EventTime] >= Time.StartOfHour(ref) and [EventTime] <= Time.EndOfHour(ref) matches all records within the same clock hour as ref. This avoids off-by-one errors from using strictly less-than comparisons.

Time.EndOfHour is most useful in near-real-time or streaming data scenarios where events are bucketed by hour. For day-level boundaries, use Date.EndOfDay/Date.StartOfDay instead.

Examples

Example 1: Add end-of-hour boundaries to log timestamps

Table.AddColumn(
    Table.SelectColumns(Table.FirstN(OrderLog, 4), {"LogID", "Timestamp"}),
    "HourEnd", each Time.EndOfHour([Timestamp]), type datetime
)
Result
LogID
Timestamp
HourEnd
1L0011/15/2024 9:30:00 AM1/15/2024 9:59:59 AM
2L0021/16/2024 2:15:00 PM1/16/2024 2:59:59 PM
3L0031/18/2024 11:00:00 AM1/18/2024 11:59:59 AM
4L0041/20/2024 8:45:00 AM1/20/2024 8:59:59 AM

Example 2: End of hour for a specific time

#table(
    type table [Result = time],
    {{Time.EndOfHour(#time(14, 30, 0))}}
)
Result
Result
114:59:59.9999999

Example 3: Build an inclusive hourly range filter

let
    RefTime = #datetime(2024, 1, 15, 9, 0, 0),
    HourStart = Time.StartOfHour(RefTime),
    HourEnd = Time.EndOfHour(RefTime)
in
    Table.SelectRows(
        OrderLog,
        each [Timestamp] >= HourStart and [Timestamp] <= HourEnd
    )
Applied Steps

The final output — filters OrderLog rows to those whose Timestamp falls within the inclusive 9 AM hour range.

LogID
OrderID
Action
Timestamp
DurationMinutes
Notes
1L0011Created1/15/2024 9:30:00 AMnullNew order: Widget A

Compatibility

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