DateTime.IsInNextSecond
DateTimeReturns true if the datetime falls in the next clock second.
Syntax
DateTime.IsInNextSecond(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 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))}
}
)Description | Timestamp | IsNextSecond | |
|---|---|---|---|
| 1 | Previous second | 3/8/2026 9:59:59 AM | FALSE |
| 2 | Current second | 3/8/2026 10:00:00 AM | FALSE |
| 3 | Next second | 3/8/2026 10:00:01 AM | TRUE |
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
)LogID | Timestamp | IsNextSecond | |
|---|---|---|---|
| 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: 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
)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 |
|---|