DateTime.IsInPreviousNHours Function in Power Query
The DateTime.IsInPreviousNHours function in Power Query indicates whether the given datetime value occurs during the previous number of hours, as determined by the current date and time on the system.
Syntax
DateTime.IsInPreviousNHours(dateTime as any, hours as number) as nullable logical
The function has the following parameters:
- dateTime: A datetime, or datetimezone value to be evaluated.
- hours: The number of hours.
Example: Let’s the current date and time in my system is 13 April 2025 11:00 AM.
Power Query M
let Source = DateTime.IsInPreviousNHours(#datetime(2025,4,13,9,40,30), 3) in Source
The output of the above code is TRUE.
Note: This function will return FALSE when passed a value that occurs within the current hour.