Date.IsInNextNYears Function in Power Query
The Date.IsInNextNYears function in Power Query indicates whether the given datetime value dateTime occurs during the next number of years, as determined by the current date and time on the system.
Syntax
Date.IsInNextNYears( dateTime as any, years as number ) as nullable logical
The function has the following parameters:
- dateTime: A value of type
date
,datetime
, ordatetimezone
to evaluate. - years: A number representing the number of years to check ahead from the current date.
Return Value:
- TRUE if the given dateTime occurs within the next N years (excluding the current year).
- FALSE otherwise.
Example: Assume today’s date is 24 August 2025.
Power Query M
let Source = Date.IsInNextNYears(#date(2027, 3, 14), 2) in Source
The output of the above code is a logical value true.