DateTime.IsInNextHour is a Power Query M function that indicates whether the provided date(time) value occurs during the next hour. The function returns true if the value occurs in the next hour, otherwise false.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
DateTime.IsInNextHour( dateTime as any ) as nullable logical
Description
DateTime.IsInNextHour indicates whether the given dateTime
argument (which can be of type datetime
or datetimezone
) occurs during the next hour, as determined by the current date and time on the system. This function will return false for a value within the current hour.
Examples
Let’s explore two examples to understand how the DateTime.IsInNextHour function works.
Checking DateTime Values for the Next Hour
Suppose you have a table with DateTime values and you want to add a column that shows true
for DateTime values that fall within the next hour. You can do this by using the DateTime.IsInNextHour function on your [DateTime]
column.
DateTime.IsInNextHour( [DateTime] ) // Output depends on [DateTime] column
This expression returns true
for any DateTime values in the [DateTime]
column that fall within the next hour.
If the current time is 10:26:14 PM on July 7, 2024, this function will return true
for all rows with DateTime values between 11:00:00 PM and 11:59:59 PM.
Here’s a screenshot to illustrate how the DateTime.IsInNextHour function works with a DateTime table:
In this example, the DateTime values increment by 15 minutes for each row. The column IsInNextHour
shows true
for the four DateTime values that fall within the next hour.
Using the Current Date and Time
If you want to check with DateTime.IsInNextHour if the current date and time falls within the next hour, you can do that using the DateTime.FixedLocalNow function and adding one hour using the #duration function:
// Output: true for the next hour
DateTime.IsInNextHour(
DateTime.FixedLocalNow() + #duration(0, 1, 0, 0)
)
Related functions
Other functions related to DateTime.IsInNextHour are:
- DateTime.IsInNextMinute
- DateTime.IsInNextNHours
- DateTime.IsInNextNMinutes
- DateTime.IsInNextNSeconds
- DateTime.IsInNextSecond
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy