How to Use Ago and Now Functions in Kusto | Kusto Query Language Tutorial (KQL)

 Topic: How to Use Ago and Now Functions in Kusto


How to use Ago and Now functions in Kusto Query | Kusto Query Language Tutorial (KQL) Kusto Query Language In this article we are going to learn about two functions one is ''now'' another one is ''ago'', now function returns the current utc clock time optionally offset by a given time span so you can provide different time spans and get the value out of that, this function can be used multiple times in a statement and the clock time being reference will be same for all the instances, so you can reference ''now'' in multiple times in the one statement and it's going to return you the same value, let's talk about ago function ago subtract the given time span from the current utc clock time so you can use ago minus 2d or minus 3d so you can subtract some days or minutes hours and all that from there go and it will return you that data.

 //Now() Function  
 //Returns the current UTC clock time, optionally offset by a given timespan. This function can be used multiple times in a statement a  
 //and the clock time being referenced will be the same for all instances.  
   
 print now()  
 //2021-11-24T23:07:15.0607137Z  
   
 print now()-2d  
   
 print now(-2d)  
   
 //ago() function -- Subtracts the given timespan from the current UTC clock time.  
   
 print now=now() //current date time  
 ,0minuteago=ago(0m) // current datetime by using ago function  
 , 1dayago=ago(1d) // one day ago   
 ,1hourago=ago(1h) //one hour ago from current datetime  
 ,1minuteago=ago(1m) // one minute ago from current datetime  
 ,1secondago=ago(1s)// one second ago from current datetime  
 ,10milisecondsago=ago(10ms) //10 mili second ago from current datetime  

Video Demo: How to Use Ago and Now Functions in Kusto | Kusto Query Language Tutorial (KQL)

No comments:

Post a Comment