DateTime.IsInPreviousHour

DateTime

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

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

Syntax

DateTime.IsInPreviousHour(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 before the current hour, false otherwise.

Remarks

DateTime.IsInPreviousHour returns true if the input datetime or datetimezone value falls within the clock hour immediately preceding the current hour (as determined by DateTime.LocalNow()). For example, if it is currently 10:xx, this function returns true for any datetime between 09:00:00 and 09:59:59.9999999. The function is re-evaluated on each query refresh.

Examples

Example 1: Filter events from the previous hour

Table.SelectRows(
    Events,
    each DateTime.IsInPreviousHour([EventTime])
)
Result
EventID
EventTime
1403/8/2026 9:10:00 AM
2413/8/2026 9:55:00 AM

Example 2: Flag previous-hour events

Table.AddColumn(
    Events,
    "IsPreviousHour", each DateTime.IsInPreviousHour([EventTime]), type logical
)
Result
EventID
EventTime
IsPreviousHour
1393/8/2026 8:55:00 AMFALSE
2403/8/2026 9:10:00 AMTRUE
3423/8/2026 10:05:00 AMFALSE

Compatibility

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