DateTime.IsInNextSecond

DateTime

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

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

Syntax

DateTime.IsInNextSecond(dateTime as any) as logical

Parameters

NameTypeRequiredDescription
dateTimeanyYesA datetime or datetimezone value to test.

Return Value

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

Remarks

DateTime.IsInNextSecond returns true if the input datetime or datetimezone value falls within the clock second immediately following the current second, as determined by DateTime.LocalNow(). The current second is not included. The function is re-evaluated on each query refresh, but in practice this is so fine-grained that it will almost never match data in a real Power Query dataset.

DateTime.IsInNextSecond is effectively a real-time streaming predicate. In any standard Power BI or Excel scenario where data is loaded from a table or database, query evaluation takes more than one second, making it practically impossible for rows to fall within the "next second" window consistently. This function is only meaningful in scenarios where M is evaluated in a true real-time engine.

For practical second-level filtering over a meaningful window, compute an explicit threshold: DateTime.LocalNow() + #duration(0, 0, 0, N) and compare directly rather than relying on the IsInNextSecond predicate.

Examples

Example 1: Demonstrate next-second evaluation

let
    Now = DateTime.FixedLocalNow()
in
    #table(
        type table [Description = text, Timestamp = datetime, IsNextSecond = logical],
        {
            {"Previous second", Now - #duration(0, 0, 0, 1), DateTime.IsInNextSecond(Now - #duration(0, 0, 0, 1))},
            {"Current second",  Now,                          DateTime.IsInNextSecond(Now)},
            {"Next second",     Now + #duration(0, 0, 0, 1), DateTime.IsInNextSecond(Now + #duration(0, 0, 0, 1))}
        }
    )
Result
Description
Timestamp
IsNextSecond
1Previous second3/8/2026 9:59:59 AMFALSE
2Current second3/8/2026 10:00:00 AMFALSE
3Next second3/8/2026 10:00:01 AMTRUE

Example 2: Flag next-second entries in log data

Table.AddColumn(
    Table.SelectColumns(Table.FirstN(OrderLog, 4), {"LogID", "Timestamp"}),
    "IsNextSecond", each DateTime.IsInNextSecond([Timestamp]), type logical
)
Result
LogID
Timestamp
IsNextSecond
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: Alternative approach using an explicit time threshold

let
    Now = DateTime.FixedLocalNow(),
    LookAheadSeconds = 5,
    Threshold = Now + #duration(0, 0, 0, LookAheadSeconds)
in
    Table.SelectRows(
        OrderLog,
        each [Timestamp] > Now and [Timestamp] <= Threshold
    )
Applied Steps

The final output — filters the OrderLog table to rows where Timestamp falls strictly between Now and the Threshold, returning an empty table because no historical rows fall in the next 5 seconds.

LogID
OrderID
Action
Timestamp
DurationMinutes
Notes

Compatibility

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