#duration

#duration is a Power Query M function that creates a duration value from numbers representing days, hours, minutes, and (fractional) seconds.

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

Syntax

#duration(
   days as number,
   hours as number,
   minutes as number,
   seconds as number,
) as duration

Description

Creates a duration value from numbers representing days, hours, minutes, and (fractional) seconds.

Examples

Returns the duration 5.10:30:59, which represents 5 days, 10 hours, 30 minutes and 59 seconds.

#duration ( 5, 10, 30, 59 )

You can easily transform a duration in a total number of seconds, minutes, hours or days.

Duration.TotalSeconds( #duration ( 5, 10, 30, 59 ) ) // returns 469859

Duration.TotalMinutes( #duration ( 5, 10, 30, 59 ) ) // returns 7830.9833333333336

Duration.TotalHours(   #duration ( 5, 10, 30, 59 ) ) // returns 130.51638888888888

Duration.TotalDays(    #duration ( 5, 10, 30, 59 ) ) // returns 5.43818287037037

Other functions related to #duration are:

BI Gorilla Blog

Last update: August 17, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/sharpduration
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.