Duration.TotalSeconds

Updated on

Duration.TotalSeconds is a Power Query M function that calculates the total seconds spanned by a duration value. The function returns a decimal number representing the total seconds.

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

Syntax

Duration.TotalSeconds( duration as nullable duration ) as nullable number

Description

The Duration.TotalSeconds function calculates the total number of seconds (including fractions) in a duration value.

Examples

The Duration.TotalSeconds function calculates the total number of seconds from a duration value. For example, a duration of 1 minute and 30 seconds returns 90 seconds:

Duration.TotalSeconds( #duration( 0, 0, 1, 30 ) ) // Output: 90

This is different from the Duration.Seconds function, as that function only retrieves the seconds portion of a duration value after subtracting the day, hours and minutes portion.

Duration.Seconds( #duration( 0, 0, 1, 30 ) ) // Output: 30

The output of Duration.TotalSeconds is also correct when the duration value specifies a combination of days, hours, minutes, and seconds. For instance, a duration of 1 day, 1 hour, and 1 minute returns 90060 seconds:

Duration.TotalSeconds(#duration( 1, 1, 1, 0 ) ) // Output: 90060

The output is the same when the duration value specifies 3600 seconds directly:

Duration.TotalSeconds( #duration( 0, 0, 60, 0 ) ) // Output: 3600

Other functions related to Duration.TotalSeconds are:

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

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