# How to calculate timestamp difference in logstash config file?

**URL:** https://discuss.elastic.co/t/how-to-calculate-timestamp-difference-in-logstash-config-file/244732
**Category:** Logstash
**Created:** [August 12, 2020, 1:58pm UTC](https://discuss.elastic.co/t/how-to-calculate-timestamp-difference-in-logstash-config-file/244732 "2020-08-12T13:58:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rahul\_Chougule](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_chougule/32/71789_2.png) [@Rahul\_Chougule](https://discuss.elastic.co/u/Rahul_Chougule)
#### Post date: [August 12, 2020, 1:58pm UTC](https://discuss.elastic.co/t/how-to-calculate-timestamp-difference-in-logstash-config-file/244732/1 "2020-08-12T13:58:38Z")

</div>

I have two timestamp fields: submit\_date("MM/dd/YYYY HH:mm") and completed date("MM/dd/YYYY HH:mm").  
I want to calculate time difference between these two fields and wanted to add it as a new field while ingesting data in Elasticsearch.

any help will be appreciated.  
Thank you.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [August 12, 2020, 2:25pm UTC](https://discuss.elastic.co/t/how-to-calculate-timestamp-difference-in-logstash-config-file/244732/2 "2020-08-12T14:25:10Z")

</div>

Parse them both using date filters, then use ruby to calculate the difference. Something like [this](https://discuss.elastic.co/t/trying-to-calculate-differences-between-2-timestamps/242443/2).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 9, 2020, 2:25pm UTC](https://discuss.elastic.co/t/how-to-calculate-timestamp-difference-in-logstash-config-file/244732/3 "2020-09-09T14:25:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
