# Calculate the time difference between consecutive documents

**URL:** https://discuss.elastic.co/t/calculate-the-time-difference-between-consecutive-documents/128282
**Category:** Elasticsearch
**Created:** [April 17, 2018, 4:40am UTC](https://discuss.elastic.co/t/calculate-the-time-difference-between-consecutive-documents/128282 "2018-04-17T04:40:44Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![MariumHassan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mariumhassan/32/30321_2.png) [@MariumHassan](https://discuss.elastic.co/u/MariumHassan)
#### Post date: [April 25, 2018, 5:50am UTC](https://discuss.elastic.co/t/calculate-the-time-difference-between-consecutive-documents/128282/13 "2018-04-25T05:50:17Z")

</div>

Hi,  
You can query data from elasticsearch and process it using any language you prefer. However, updating that data after processing it in this way might be an issue here. I think you will need to update it by query or you can simply get/store document id of the document you want to update and use that to update the document later.  
This is helpful: [Logstash Update a document in elasticsearch](https://discuss.elastic.co/t/logstash-update-a-document-in-elasticsearch/74039/5)

---

_[View the full topic](https://discuss.elastic.co/t/calculate-the-time-difference-between-consecutive-documents/128282)._
