DateTime.IsInNextNSeconds
DateTimeReturns true if the datetime falls within the next N seconds.
Syntax
DateTime.IsInNextNSeconds(dateTime as any, seconds as number) as logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A datetime or datetimezone value to test. |
seconds | number | Yes | The number of seconds ahead to include. Must be a positive integer. |
Return Value
logical — true 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 | |
|---|---|---|
| 1 | 70 | 3/8/2026 10:32:55 AM |
| 2 | 71 | 3/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 | |
|---|---|---|---|
| 1 | 69 | 3/8/2026 10:32:44 AM | FALSE |
| 2 | 70 | 3/8/2026 10:32:55 AM | TRUE |
| 3 | 72 | 3/8/2026 10:34:00 AM | FALSE |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks