Date.IsInNextNYears
DateReturns true if the date falls within the next N calendar years.
Syntax
Date.IsInNextNYears(dateTime as any, years as number) as logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A date, datetime, or datetimezone value to test. |
years | number | Yes | The number of years ahead to include. Must be a positive integer. |
Return Value
logical — true if the date falls within the next N years after the current year, false otherwise.
Remarks
Date.IsInNextNYears returns true if the input date falls within the next N complete calendar years after the current year. The current year itself is not included; use Date.IsInCurrentYear to also match the current year. The function is re-evaluated on each query refresh.
For example, if the current year is 2026 and years = 3, it matches any date in 2027, 2028, or 2029. This function counts whole calendar years (January 1 through December 31), not a rolling 365-day window. For a rolling window, use Date.IsInNextNDays(n * 365) or compute the boundary dates explicitly.
Use this function for medium-term planning scenarios such as multi-year contract expiration reporting, asset replacement schedules, or budget forecasting horizons.
Examples
Example 1: Find orders due in the next 2 years
Table.SelectRows(
Sales,
each Date.IsInNextNYears([OrderDate], 2)
)OrderID | CustomerName | OrderDate | |
|---|---|---|---|
| 1 | 50 | Alice | 3/15/2027 |
| 2 | 51 | Bob | 9/22/2027 |
Example 2: Flag long-term orders
Table.AddColumn(
Sales,
"DueInNext5Years", each Date.IsInNextNYears([OrderDate], 5), type logical
)OrderID | OrderDate | DueInNext5Years | |
|---|---|---|---|
| 1 | 42 | 3/8/2026 | FALSE |
| 2 | 50 | 3/15/2027 | TRUE |
| 3 | 55 | 1/1/2032 | FALSE |
Example 3: Combine current year and next 2 years for a 3-year view
Table.SelectRows(
Sales,
each Date.IsInCurrentYear([OrderDate]) or Date.IsInNextNYears([OrderDate], 2)
)OrderID | CustomerName | OrderDate | |
|---|---|---|---|
| 1 | 42 | Charlie | 3/8/2026 |
| 2 | 50 | Alice | 3/15/2027 |
| 3 | 51 | Bob | 9/22/2027 |