DateTime.IsInCurrentHour

DateTime

Returns true if the datetime falls within the current hour.

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

Syntax

DateTime.IsInCurrentHour(dateTime as any) as logical

Parameters

NameTypeRequiredDescription
dateTimeanyYesA datetime or datetimezone value to test.

Return Value

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

Remarks

DateTime.IsInCurrentHour returns true if the input datetime or datetimezone value falls within the same clock hour as now, as determined by DateTime.LocalNow(). The hour window runs from HH:00:00 to HH:59:59.9999999. The function is re-evaluated on each query refresh, so results will differ between refreshes depending on the current time.

All DateTime.IsIn* functions use the local system clock (DateTime.LocalNow) as their reference point. In Power BI Service and Dataflows, "local" typically means the cloud region's system time (often UTC), not your personal timezone. Keep this in mind when using these functions in cloud-refresh scenarios — a filter for "current hour" may behave unexpectedly if the service timezone differs from your data's timezone.

These fine-grained time functions (IsInCurrentHour, IsInNextHour, IsInPreviousHour) are most useful in streaming or near-real-time data pipelines where data is refreshed frequently — not in standard daily-refresh Power BI reports. Combine with DateTime.IsInCurrentMinute or similar for even more precise filtering.

Examples

Example 1: Filter events from the current hour

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

Example 2: Flag current-hour rows

Table.AddColumn(
    Table.SelectColumns(Table.FirstN(OrderLog, 4), {"LogID", "Timestamp"}),
    "IsCurrentHour", each DateTime.IsInCurrentHour([Timestamp]), type logical
)
Result
LogID
Timestamp
IsCurrentHour
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: Combine current and previous hour for a two-hour window

Table.AddColumn(
    Table.SelectColumns(Table.FirstN(OrderLog, 4), {"LogID", "Timestamp"}),
    "InRecentHour",
    each DateTime.IsInCurrentHour([Timestamp]) or DateTime.IsInPreviousHour([Timestamp]),
    type logical
)
Result
LogID
Timestamp
InRecentHour
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