Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

format_datetime() in Kusto for datetime with minutes and secounds as 00

In the azure data explorer documentation, there is a lot of supported formats but not the one that i am looking for.

What I need is to format the datetime like "yyyy-MM-dd HH" to set the minutes and seconds as 0

Input datetime

2020-04-21T17:44:27.6825985Z

expected results

2020-04-21 17:00:00
like image 508
MaxDev Avatar asked Dec 18 '25 19:12

MaxDev


1 Answers

you can use bin() to round down to the hour, and if you still need to remove the datetime parts lower than seconds, you can use substring() (or format_datetime()). e.g.:

print d = datetime(2020-04-21T17:44:27.6825985Z)
| extend h = bin(d, 1h)
| extend h2 = substring(h, 0, 19)
like image 74
Yoni L. Avatar answered Dec 21 '25 12:12

Yoni L.