DateTime.IsInPreviousMinute

Updated on

DateTime.IsInPreviousMinute is a Power Query M function that indicates whether the provided date(time) value occurs during the previous minute. The function returns true if the value occurs in the previous minute, otherwise false.

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

Syntax

DateTime.IsInPreviousMinute( dateTime as any ) as nullable logical

Description

DateTime.IsInPreviousMinute indicates whether the given dateTime argument (which can be of type datetime or datetimezone) occurs during the previous minute, as determined by the current date and time on the system. This function will return false for a value within the current minute.

Examples

Let’s explore two examples to understand how the DateTime.IsInPreviousMinute function works.

Checking DateTime Values for the Previous Minute

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 previous minute. You can do this by using the DateTime.IsInPreviousMinute function on your [DateTime] column.

DateTime.IsInPreviousMinute( [DateTime] ) // Output depends on [DateTime] column

This expression returns true for any DateTime values in the [DateTime] column that fall within the previous minute.

If the current time is 10:24:46 PM on July 7, 2024, this function will return true for all rows with DateTime values between 10:23:00 PM and 10:23:59 PM.

Here’s a screenshot to illustrate how the DateTime.IsInPreviousMinute function works with a DateTime table:

Example of how to use the DateTime.IsInPreviousMinute Function in Power Query M

In this example, the DateTime values increment by one minute for each row. The column IsInPreviousMinute shows true for DateTime values that fall within the minute preceding the current time.

Using the Current Date and Time

If you want to check with DateTime.IsInPreviousMinute if the current date and time falls within the previous minute, you can do that using the DateTime.FixedLocalNow function and subtracting one minute using the #duration function:

// Output: true
DateTime.IsInPreviousMinute(
  DateTime.FixedLocalNow() - #duration(0, 0, 1, 0)
)

Other functions related to DateTime.IsInPreviousMinute are:

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

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy