Time.EndOfHour
TimeReturns the last moment of the hour for the given time or datetime value.
Syntax
Time.EndOfHour(dateTime as any) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A time, datetime, or datetimezone value. |
Return Value
any — A 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
)LogID | Timestamp | HourEnd | |
|---|---|---|---|
| 1 | L001 | 1/15/2024 9:30:00 AM | 1/15/2024 9:59:59 AM |
| 2 | L002 | 1/16/2024 2:15:00 PM | 1/16/2024 2:59:59 PM |
| 3 | L003 | 1/18/2024 11:00:00 AM | 1/18/2024 11:59:59 AM |
| 4 | L004 | 1/20/2024 8:45:00 AM | 1/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 | |
|---|---|
| 1 | 14: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
)The final output — filters OrderLog rows to those whose Timestamp falls within the inclusive 9 AM hour range.
LogID | OrderID | Action | Timestamp | DurationMinutes | Notes | |
|---|---|---|---|---|---|---|
| 1 | L001 | 1 | Created | 1/15/2024 9:30:00 AM | null | New order: Widget A |