Date.IsInNextNWeeks Function in Power Query
The Date.IsInNextNWeeks function in Power Query (M language) is used to determine whether a given date occurs within the next n weeks (excluding the current week) based on the current system date and time.
Syntax
Date.IsInNextNWeeks( dateTime as any, weeks as number ) as nullable logical
The function has the following parameters:
- dateTime: A value of type
date
,datetime
, ordatetimezone
that you want to test. - weeks: A number specifying how many weeks ahead to check.
Return Value
- Returns true if the date falls within the next n weeks, otherwise false.
- Returns false if the date falls within the current week.
- Returns null if the input is null.
Example: Check if 1st September 2025 falls in the next 2 weeks when today's date is 24th August 2025.
Power Query M
let Source = Date.IsInNextNWeeks(#date(2025, 9, 1), 2) in Source
The output of the above code is logical value true.