# How to calculate duration in aggregation?

**URL:** <https://discuss.elastic.co/t/how-to-calculate-duration-in-aggregation/53644>\
**Category:** Elasticsearch\
**Created:** [June 22, 2016, 9:59am UTC](https://discuss.elastic.co/t/how-to-calculate-duration-in-aggregation/53644 "2016-06-22T09:59:55Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [June 22, 2016, 3:07pm UTC](https://discuss.elastic.co/t/how-to-calculate-duration-in-aggregation/53644/4 "2016-06-22T15:07:29Z")

</div>

Toughest question to answer on an event store is something like "what is the average duration of web sessions on my website?". This looks like that sort of question.

Why it is hard and how to solve it is covered in the "entity centric indexing" talk here: [https://www.youtube.com/watch?v=yBf7oeJKH2Y](https://www.youtube.com/watch?v=yBf7oeJKH2Y)

It includes example scripts you can download.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-calculate-duration-in-aggregation/53644)._
