Forum Discussion

Rince91's avatar
Rince91
Helper I
6 years ago
Solved

Convert DateTime to Total HH:MM:SS

I have a column that is the raw out put of how long it has taken to respond to a ticket.

 

It is in the format dd/mm/yyyy hh:mm:ss

 

However the date starts at 01/01/4000 00:00:00. Screenshot below:

I need to covert it to a total durtaion i.e. 48:53:20 (HH:MM:SS) so that i can take an average of these values in another measure.

 

Any ideas how to do this? i have tried datediff but that only returns it ina  single format of HOURS or Minutes etc...

  • Hi Rince91 

    power bi desktop isn't able to format time beyond 23:59:59. In Excel you can use square brackets like this [hh]:mm:ss. Use a calculated column with the following formula:

    Total Time = 
    VAR _Difference = 'Table'[End] - 'Table'[Start]
    VAR _Days = INT(_Difference)
    VAR _Hours = HOUR(_Difference)
    VAR _Minutes = MINUTE(_Difference)
    VAR _Seconds = SECOND(_Difference)
    VAR _DaysToHours = _Days * 24
    VAR _TotalHours = _DaysToHours + _Hours
    RETURN
        FORMAT(_TotalHours, "00") & ":" & FORMAT(_Minutes, "00") & ":" & FORMAT(_Seconds,"00")

     

     

    Regards FrankAT

     

6 Replies