Kusto Query Earliest and Latest date in the Past 21 days

Angela picture Angela · Jun 30, 2017 · Viewed 9.3k times · Source

So I am new to kusto and I am trying to get the min and max dates of the past 21 days in a kusto query and I want to project those min and max dates.

How do I modify this simple query to get the min and max dates of the past 21 days?

customEvents
| where timestamp >= ago(21d)
| project timestamp

Answer

Yoni picture Yoni · Jul 1, 2017

you can use summarize with max() and min() as follows:

customEvents | where timestamp >= ago(21d) | summarize min(timestamp), max(timestamp)