How to convert seconds to format HH:mm:ss in Kusto

Viewed 3389

I would like to know the best way to transform a duration in seconds in something more user friendly like HH:MM:SS.

I have found a solution, but I don't think it's the best one:

I use a random datetime make_datetime(2017,1,1), I add the amount of seconds with datetime_add and then I format the result to get "HH:mm:ss"

AzureDiagnostics 

| project  

Duration = format_datetime(
                   datetime_add('second',
                                toint(Output_copyDuration_d),
                                make_datetime(2017,1,1)
                                ),
                   "HH:mm:ss")

where Output_copyDuration_d is the duration stored in seconds

My results are correct

if Output_copyDuration_d = 234 then I get Duration = 00:03:54

1 Answers
Related