DateTime.IsInNextNSeconds

DateTime

Returns true if the datetime falls within the next N seconds.

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

Syntax

DateTime.IsInNextNSeconds(dateTime as any, seconds as number) as logical

Parameters

NameTypeRequiredDescription
dateTimeanyYesA datetime or datetimezone value to test.
secondsnumberYesThe number of seconds ahead to include. Must be a positive integer.

Return Value

logicaltrue if the datetime falls within the next N seconds after the current second, false otherwise.

Remarks

DateTime.IsInNextNSeconds returns true if the input datetime or datetimezone value falls within the next N complete seconds after the current second. The current second is not included; use DateTime.IsInCurrentSecond to also match the current second. The function is re-evaluated on each query refresh.

Examples

Example 1: Filter events in the next 30 seconds

Table.SelectRows(
    Events,
    each DateTime.IsInNextNSeconds([EventTime], 30)
)
Result
EventID
EventTime
1703/8/2026 10:32:55 AM
2713/8/2026 10:33:10 AM

Example 2: Flag events in the next 60 seconds

Table.AddColumn(
    Events,
    "InNext60Sec", each DateTime.IsInNextNSeconds([EventTime], 60), type logical
)
Result
EventID
EventTime
InNext60Sec
1693/8/2026 10:32:44 AMFALSE
2703/8/2026 10:32:55 AMTRUE
3723/8/2026 10:34:00 AMFALSE

Compatibility

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