# Calculation time difference between two document

**URL:** <https://discuss.elastic.co/t/calculation-time-difference-between-two-document/174876>\
**Category:** Kibana\
**Created:** [April 1, 2019, 9:12pm UTC](https://discuss.elastic.co/t/calculation-time-difference-between-two-document/174876 "2019-04-01T21:12:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Pradyumna\_Jha](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@Pradyumna\_Jha](https://discuss.elastic.co/u/Pradyumna_Jha)\
**Post date:** [April 1, 2019, 11:01pm UTC](https://discuss.elastic.co/t/calculation-time-difference-between-two-document/174876/5 "2019-04-01T23:01:00Z")

</div>

This seems to be the only solution.

> [@Compare fields in two documents?](https://discuss.elastic.co/t/compare-fields-in-two-documents/116548/2):
>
> Scripted fields can only calculate data WITHIN one document. You CANNOT calculate data across multiple documents. To achieve writing that diff, you will need to measure it before indexing the documents, so that you write the time diff to the ending document. In Logstash e.g. the [elapsed](https://www.elastic.co/guide/en/logstash/current/plugins-filters-elapsed.html) plugin can achieve that. Cheers, Tim

---

_[View the full topic](https://discuss.elastic.co/t/calculation-time-difference-between-two-document/174876)._
