DateTime.IsInNextHour

DateTime

Returns true if the datetime falls in the next clock hour.

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

Syntax

DateTime.IsInNextHour(dateTime as any) as logical

Parameters

NameTypeRequiredDescription
dateTimeanyYesA datetime or datetimezone value to test.

Return Value

logicaltrue if the datetime falls within the clock hour immediately after the current hour, false otherwise.

Remarks

DateTime.IsInNextHour returns true if the input datetime or datetimezone value falls within the clock hour immediately following the current hour, as determined by DateTime.LocalNow(). For example, if it is currently 10:xx, this function returns true for any datetime between 11:00:00 and 11:59:59.9999999. The current hour itself is not included — use DateTime.IsInCurrentHour to also match the current hour. The function is re-evaluated on each query refresh.

Like all DateTime.IsIn* functions, this uses the local system clock as its reference. In Power BI Service and Dataflows, the "local" clock typically reflects UTC (the cloud region's system time), not your personal timezone. Keep this in mind when deploying solutions that use hour-level filtering in cloud-refresh scenarios.

DateTime.IsInNextHour is most practical in near-real-time or streaming scenarios where data is loaded continuously and you want to flag upcoming events or scheduled tasks within the next clock hour. For broader lookahead windows, use DateTime.IsInNextNHours.

Examples

Example 1: Filter events scheduled for the next hour

Table.SelectRows(
    OrderLog,
    each DateTime.IsInNextHour([Timestamp])
)
Result
LogID
OrderID
Action
Timestamp
DurationMinutes
Notes

Example 2: Flag next-hour log entries

Table.AddColumn(
    Table.SelectColumns(Table.FirstN(OrderLog, 4), {"LogID", "Timestamp"}),
    "IsNextHour", each DateTime.IsInNextHour([Timestamp]), type logical
)
Result
LogID
Timestamp
IsNextHour
1L0011/15/2024 9:30:00 AMFALSE
2L0021/16/2024 2:15:00 PMFALSE
3L0031/18/2024 11:00:00 AMFALSE
4L0041/20/2024 8:45:00 AMFALSE

Example 3: Build a two-hour alert window (current + next hour)

Table.AddColumn(
    Table.SelectColumns(Table.FirstN(OrderLog, 4), {"LogID", "Timestamp"}),
    "AlertWindow",
    each DateTime.IsInCurrentHour([Timestamp]) or DateTime.IsInNextHour([Timestamp]),
    type logical
)
Result
LogID
Timestamp
AlertWindow
1L0011/15/2024 9:30:00 AMFALSE
2L0021/16/2024 2:15:00 PMFALSE
3L0031/18/2024 11:00:00 AMFALSE
4L0041/20/2024 8:45:00 AMFALSE

Compatibility

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