Reputation: 7383
How can I convert time difference into milliseconds in Azure Application Insights
let startTime = todatetime('2017-05-15T17:02:23.7148691Z');
let endTime = todatetime('2017-05-15T17:02:25.5430172Z');
let timeDifference = endTime-startTime;
requests
| project timeDifference
| limit 1
The above query outputs
00:00:01.8281481
I would like to display it in milliseconds
For ex: 1828
Upvotes: 3
Views: 4350
Reputation: 64
Another solution is to use the built-in datetime_diff
function and specify milliseconds:
let startTime = todatetime('2017-05-15T17:02:23.7148691Z');
let endTime = todatetime('2017-05-15T17:02:25.5430172Z');
let timeDifference = datetime_diff("Millisecond", endTime, startTime);
requests
| project timeDifference
| limit 1
Documentation is here: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/datetime-difffunction
Upvotes: 1
Reputation: 6241
You can divide your timespan by another timespan. So, to get number of milliseconds you can do the following:
let startTime = todatetime('2017-05-15T17:02:23.7148691Z');
let endTime = todatetime('2017-05-15T17:02:25.5430172Z');
let timeDifference = endTime-startTime;
// get total milliseconds
requests
| extend timeDifferenceMilliseconds = timeDifference / time(1ms)
| project timeDifferenceMilliseconds
| limit 1
More about date and time expressions can be found here: https://learn.microsoft.com/en-us/azure/application-insights/app-insights-analytics-reference#date-and-time-expressions
Upvotes: 3