Duration.TotalHours Function of Power Query
The Duration.TotalHours function in Power Query, returns the total number of hours in a Duration value.
Syntax
Duration.TotalHours(duration as nullable duration) as nullable number
The parameter duration represents a time span (e.g., 2 days, 3 hours, 15 minutes). It returns a numeric value (a decimal) representing the total hours, including fractional hours.
Example: Find the total hours spanned by a duration value.
Power Query M
let source = Duration.TotalHours(#duration(1, 2, 30, 0)) in source
The output of the above code is 26.5.
The following points explain how we get 26.5.
• #duration(1, 2, 30, 0) means 1 day, 2 hours, 30 minutes, and 0 seconds.
• Calculation: (1 day × 24 hours) + 2 hours + (30 minutes ÷ 60) = 24 + 2 + 0.5 = 26.5 hours.
Note: 1 days is equal to 24 hours.