Date.IsInNextNMonths Function in Power Query
The Date.IsInNextNMonths function in Power Query checks whether a given datetime value falls within the next N months, excluding the current month, as determined by the current date and time on the system.
Syntax
Date.IsInNextNMonths( dateTime as any, months as number ) as nullable logical
The function has the following parameters:
- dateTime: A date, datetime, or datetimezone value to be evaluated.
- months: The number of months.
Returns
- TRUE if dateTime falls within the next N months (excluding the current month).
- FALSE otherwise.
Example: Let’s the current date in the system is 3 April 2025.
Power Query M
let Source = Date.IsInNextNMonths(#date(2025, 4, 5), 1) in Source
The output of the above code is FALSE.
Note: This function will return false when passed a value that occurs within the current month.