How to get the minutes from a timespan in KQL

Viewed 4285

I wanted to extract the time in minutes for a Kusto query I was working on. I have a cloumn where timespan is represented in the following format (HH:MM:SS.MilliSeconds) 01:18:54.0637555. I wanted to extract the number of minutes from this in this case 78 minutes. How can I do that ?

2 Answers

If you just need to print the timespan parts, you can create a small user-defined function to collect each part of the timespan:

let print_timespan = (input: timespan) {
    iif(
    isempty(input), "",
    strcat(
        format_timespan(input, 'dd'), "d ",
        format_timespan(input, 'hh'), "h ",
        format_timespan(input, 'mm'), "m ",
        format_timespan(input, 'ss'), "s ")
    )
};
let t = time(29.09:00:05.12345);
print print_timespan(t)


---

29d 09h 00m 05s 
Related