Date.IsInPreviousNDays

Updated on

Date.IsInPreviousNDays is a Power Query M function that indicates whether the given date(time) value occurs during the previous number of days, as determined by the system. The function returns a boolean value (true or false).

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Date.IsInPreviousNDays(
   dateTime as any,
   days as number,
) as nullable logical

Description

Date.IsInPreviousNDays determines if a datetime value is within a specified number of days before the current system date and time. It excludes current day values. You can provide a date, datetime or datetimezone as input value, and the number of days to look back at.

Examples

Determine if the day before the current system time is in the previous two days.

// Output: true
Date.IsInPreviousNDays( Date.AddDays( DateTime.FixedLocalNow(), -1 ), 2 )

Other functions related to Date.IsInPreviousNDays are:

BI Gorilla Youtube Channel

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/date-isinpreviousndays