# How to calculate difference of two dates and display the result in seconds(integer type) through scripted fields in kibana

**URL:** <https://discuss.elastic.co/t/how-to-calculate-difference-of-two-dates-and-display-the-result-in-seconds-integer-type-through-scripted-fields-in-kibana/168179>\
**Category:** Kibana\
**Created:** [February 13, 2019, 10:07am UTC](https://discuss.elastic.co/t/how-to-calculate-difference-of-two-dates-and-display-the-result-in-seconds-integer-type-through-scripted-fields-in-kibana/168179 "2019-02-13T10:07:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PRUDHVI\_CHOWDHARY\_NE](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@PRUDHVI\_CHOWDHARY\_NE](https://discuss.elastic.co/u/PRUDHVI_CHOWDHARY_NE)\
**Post date:** [February 13, 2019, 10:07am UTC](https://discuss.elastic.co/t/how-to-calculate-difference-of-two-dates-and-display-the-result-in-seconds-integer-type-through-scripted-fields-in-kibana/168179/1 "2019-02-13T10:07:58Z")

</div>

I have two dates in a index

t1 : February 12th 2019, 11:54:48.000

t2 : February 12th 2019, 11:56:10.000

the result t2-t1=execution time(in my case).Now how to calculate t2-t1 and display result in seconds .Here execution time should be of integer type.this should be done in scripted fields in kibana .Help me out

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [February 18, 2019, 11:56pm UTC](https://discuss.elastic.co/t/how-to-calculate-difference-of-two-dates-and-display-the-result-in-seconds-integer-type-through-scripted-fields-in-kibana/168179/2 "2019-02-18T23:56:11Z")

</div>

Yep. You can definitely use scripted fields for it.

Here is an example where we are extracting hour of the day:

 ![54%20PM](https://us1.discourse-cdn.com/elastic/original/3X/5/2/52aef86084f10d91e72ebe650598e51831d35988.png)

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html)

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![PRUDHVI\_CHOWDHARY\_NE](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@PRUDHVI\_CHOWDHARY\_NE](https://discuss.elastic.co/u/PRUDHVI_CHOWDHARY_NE)\
**Post date:** [February 19, 2019, 11:43am UTC](https://discuss.elastic.co/t/how-to-calculate-difference-of-two-dates-and-display-the-result-in-seconds-integer-type-through-scripted-fields-in-kibana/168179/3 "2019-02-19T11:43:47Z")

</div>

can we run kibana v 6.6.0 with elastic search v6.0.1

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [February 19, 2019, 4:16pm UTC](https://discuss.elastic.co/t/how-to-calculate-difference-of-two-dates-and-display-the-result-in-seconds-integer-type-through-scripted-fields-in-kibana/168179/4 "2019-02-19T16:16:35Z")

</div>

Hello,

Unfortunately that is not possible:  
[https://www.elastic.co/support/matrix#matrix\_compatibility](https://www.elastic.co/support/matrix#matrix_compatibility)

Thanks,  
Bhavya

---

<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:** [March 19, 2019, 4:32pm UTC](https://discuss.elastic.co/t/how-to-calculate-difference-of-two-dates-and-display-the-result-in-seconds-integer-type-through-scripted-fields-in-kibana/168179/5 "2019-03-19T16:32:04Z")

</div>

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