DateTime.IsInNextSecond is a Power Query M function that indicates whether the provided date(time) value occurs during the next second. The function returns true if the value occurs in the next second, otherwise false.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
DateTime.IsInNextSecond( dateTime as any ) as nullable logical
Description
DateTime.IsInNextSecond indicates whether the given dateTime
argument (which can be of type datetime
or datetimezone
) occurs during the next second, as determined by the current date and time on the system. This function will return false for a value within the current second.
Examples
Let’s explore two examples to understand how the DateTime.IsInNextSecond function works.
Checking DateTime Values for the Next 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 next second. You can do this by using the DateTime.IsInNextSecond
function on your [DateTime]
column.
DateTime.IsInNextSecond( [DateTime] ) // Output depends on [DateTime] column
This expression returns true
for any DateTime values in the [DateTime]
column that fall within the next second.
You might wonder what types of values can fall within the next second. We’re talking about values that occur in the immediate next second taking into account the fractional portion of seconds. For example, if the current time is 22:13:34.664 on July 7, 2024, this function will return true
for all rows with DateTime values between 22:13:35.000 and 22:13:35.999.
Here’s a screenshot showing this:
As you can see, there are several values that fall within the next second. And 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.IsInNextSecond if the current date and time falls within the next second, you can do that using the DateTime.FixedLocalNow function. This function retrieves the current date and time.
// Output: true for the next second
DateTime.IsInNextSecond( DateTime.FixedLocalNow() + #duration( 0, 0, 0, 0.5 ) )
Related functions
Other functions related to DateTime.IsInNextSecond are:
- DateTime.IsInNextHour
- DateTime.IsInNextMinute
- DateTime.IsInNextNHours
- DateTime.IsInNextNMinutes
- DateTime.IsInNextNSeconds
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy