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 ?
Asked
Active
Viewed 8,971 times
2 Answers
10
Try dividing the timespan value by 1min
, as explained here: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/datetime-timespan-arithmetic

Yoni L.
- 22,627
- 2
- 29
- 48
-
Thanks! You saved my day! By the way, you can divide that to other values like 1h to convert the timespan to total hours. – Anduin Xue Nov 06 '21 at 09:05
0
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

Mário Meyrelles
- 1,594
- 21
- 26