Duration.TotalDays

Updated on

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

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

Syntax

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

Description

The Duration.TotalDays function calculates the total number of days (including fractions) in a duration.

Examples

Let’s see how we can use the Duration.TotalDays function.

Calculating Total Days from a Duration Value

The Duration.TotalDays function calculates the total number of days from a duration value. For example, a duration of 1 day and 12 hours returns 1.5 days:

Duration.TotalDays( #duration( 1, 12, 0, 0 ) ) // Output: 1.5

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

Duration.Days( #duration( 1, 12, 0, 0 ) ) // Output: 1

The output of Duration.TotalDays is also correct when the duration value specifies a combination of days, hours, minutes, and seconds. For instance, a duration of 2 days, 3 hours, and 30 minutes returns 2.145833 days:

Duration.TotalDays( #duration( 2, 3, 30, 0 ) ) // Output: 2.145833333333333

By using Duration.TotalDays, you can easily compute the total number of days within a duration, regardless of how the duration is composed.

Other functions related to Duration.TotalDays are:

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

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