DateTime.IsInCurrentHour
DateTimeReturns true if the datetime falls within the current hour.
Syntax
DateTime.IsInCurrentHour(dateTime as any) as logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A datetime or datetimezone value to test. |
Return Value
logical — true 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])
)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
)LogID | Timestamp | IsCurrentHour | |
|---|---|---|---|
| 1 | L001 | 1/15/2024 9:30:00 AM | FALSE |
| 2 | L002 | 1/16/2024 2:15:00 PM | FALSE |
| 3 | L003 | 1/18/2024 11:00:00 AM | FALSE |
| 4 | L004 | 1/20/2024 8:45:00 AM | FALSE |
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
)LogID | Timestamp | InRecentHour | |
|---|---|---|---|
| 1 | L001 | 1/15/2024 9:30:00 AM | FALSE |
| 2 | L002 | 1/16/2024 2:15:00 PM | FALSE |
| 3 | L003 | 1/18/2024 11:00:00 AM | FALSE |
| 4 | L004 | 1/20/2024 8:45:00 AM | FALSE |