How can I summarize records by year, month,day and hour only?
Asked
Active
Viewed 2.4k times
35
-
2Are you using [Application Insights Analytics](https://learn.microsoft.com/en-us/azure/application-insights/app-insights-analytics)? If so, try [datepart](https://learn.microsoft.com/en-us/azure/application-insights/app-insights-analytics-reference#datepart) – Peter Bons Jun 06 '17 at 13:37
1 Answers
88
In Application Insights Analytics:
By hour:
requests
| summarize count() by bin(timestamp, 1h)
By day:
requests
| summarize count() by bin(timestamp, 1d)
By month
requests
| summarize count() by bin(datepart("Month", timestamp), 1)
By year
requests
| summarize count() by bin(datepart("Year", timestamp), 1)

Jeremy Hutchinson
- 1,975
- 16
- 26
-
10Just wanted to mention that there are also aliases for this: startofday(timestamp), startofweek, startofmonth and startofyear. it should be a bit easier to use. – Asaf Strassberg Jun 07 '17 at 09:15