DateTime.IsInCurrentSecond

Updated on

DateTime.IsInCurrentSecond is a Power Query M function that indicates whether the provided date(time) value occurs during the current second. The function returns true if the value occurs within the current second, otherwise false.

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

Syntax

DateTime.IsInCurrentSecond( dateTime as any ) as nullable logical

Description

DateTime.IsInCurrentSecond indicates whether the given dateTime argument (which can be of type datetime or datetimezone) occurs during the current second, as determined by the current date and time on the system.

Examples

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

Checking DateTime Values for the Current Second

Imagine 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 second. You can do this by using the DateTime.IsInCurrentSecond function on your [DateTime] column.

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

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

You might wonder what types of values can fall within the same second. We’re talking about values that may have different fractional seconds but still fall within the exact same second. For example, if the current second is 22:07:56.539 on July 7, 2024, this function will return true for all rows with DateTime values within that specific second.

Here’s a screenshot showing this:

How to use the DateTime.IsInCurrentSecond Function in Power Query M

As you can see, there are four values that fall within the current second. Although the default DateTime value does not display fractional seconds, you can view the detailed values in the [DateTime Text] column, which uses a format string that includes fractional seconds.

Using the Current Date and Time

If you want to check with DateTime.IsInCurrentSecond if the current date and time falls within the current second you can do that using the DateTime.FixedLocalNow function. This function retrieves the current date and time.

// Output: true
DateTime.IsInCurrentSecond( DateTime.FixedLocalNow() )

Other functions related to DateTime.IsInCurrentSecond are:

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

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