Duration.TotalDays Function of Power Query
The Duration.TotalDays function in Power Query, returns the total number of days from a Duration value.
Syntax
Duration.TotalDays(duration as nullable duration) as nullable number
• duration: A duration type input (e.g., from #duration(days, hours, minutes, seconds)).
Returns: It returns a number, representing the total days as a decimal value.
Example: Find the total days spanned by a duration value.
Power Query M
let source = Duration.TotalDays(#duration(1, 2, 30, 0)) in source
The output of the above code is 1.1041666666666665.
Calculation: • 1 day = 1 day
• 2 hours = 2÷24=0.083333... days (since there are 24 hours in a day)
• 30 minutes = 30 ÷ (24×60) = 30 ÷ 1440 = 0.020833... days (since there are 1440 minutes in a day)
Total = 1+0.083333...+0.020833...=1.104166.. days
So, Duration.TotalDays(#duration(1, 2, 30, 0)) returns approximately 1.1041666.