0
votes

This line is in my Azure Application Insights Kusto query:

pageViews 
| where timestamp between(datetime("2020-03-06T00:00:00.000Z")..datetime("2020-06-06T00:00:00.000Z"))

Each time I run it, I manually replace the datetime values with current date and the current date minus ~90 days. Is there a way to write the query in a way that no matter what day I run it, it uses that day minus 90 days by default?

The reason for 90 is I believe Azure Application Insights allows a maximum of the most recent 90 days to exported. In other queries I might choose to use minus 30 days or minus 7 days, if it's possible.

If this is easily spotted in Microsoft documentation and I have missed it in my exploration, I apologize.

Thank you for any insight anyone may have.

2

2 Answers

3
votes

IIUC, you're interested in running something like this:

pageViews 
| where timestamp between(startofday(ago(90d)) .. startofday(now()))

(depending on your requirement, you can omit the startofday()s, or use endofday(), or perform any other datetime-manipulation/arithmetics)

2
votes

It should be easy to use ago operator. The query is as below:

pageViews
| where timestamp >ago(90d) //d means days here.

And for this The reason for 90 is I believe Azure Application Insights allows a maximum of the most recent 90 days to exported. You can take a look at Continuous Export feature, it's different from export via query. And you can choose the better one between them as per your requirement.