DateTime.IsInCurrentHour is a Power Query M function that indicates whether the provided date(time) value occurs during the current hour, as determined by the system.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
DateTime.IsInCurrentHour( dateTime as any ) as nullable logical
Description
DateTime.IsInCurrentHour indicates whether the given dateTime
argument (which can be of type datetime
or datetimezone
) occurs during the current hour, as determined by the current date and time on the system.
Examples
Let’s explore two examples to understand how the DateTime.IsInCurrentHour function works.
Checking DateTime Values for the Current 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 current hour. You can do this by using the DateTime.IsInCurrentHour function on your [DateTime]
column.
DateTime.IsInCurrentHour( [DateTime] ) // Output depends on [DateTime] column
This expression returns true
for any DateTime values in the [DateTime]
column that fall within the current hour.
If the current time is 9:55:37 PM on July 7, 2024, this function will return true
for all rows with DateTime values between 9:00:00 PM and 9:59:59 PM.
Here’s a screenshot to illustrate how the DateTime.IsInCurrentHour function works with a DateTime table:
In this example, the DateTime values increment by fifteen minutes for each row. The column IsInCurrentHour
shows true
for the four DateTime values that fall within the current hour.
Using the Current Date and Time
If you want to check with DateTime.IsInCurrentHour if the current date and time falls within the current hour, you can do that using the DateTime.FixedLocalNow function:
// Output: true
DateTime.IsInCurrentHour(
DateTime.FixedLocalNow()
)
Related functions
Other functions related to DateTime.IsInCurrentHour are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy