# Kibana 5.1 possible to calculate time difference and place it in a field in kibana at runtime?

**URL:** <https://discuss.elastic.co/t/kibana-5-1-possible-to-calculate-time-difference-and-place-it-in-a-field-in-kibana-at-runtime/73387>\
**Category:** Kibana\
**Created:** [January 31, 2017, 3:41pm UTC](https://discuss.elastic.co/t/kibana-5-1-possible-to-calculate-time-difference-and-place-it-in-a-field-in-kibana-at-runtime/73387 "2017-01-31T15:41:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)\
**Post date:** [January 31, 2017, 3:41pm UTC](https://discuss.elastic.co/t/kibana-5-1-possible-to-calculate-time-difference-and-place-it-in-a-field-in-kibana-at-runtime/73387/1 "2017-01-31T15:41:04Z")

</div>

Hi there,

I know I can do many cool stuff in logstash, for example calculating time differences and store it in a field.  
Now my question, is it possible to do such stuff in kibana in realtime too?

Say, I have following timestamps in my event

- @timestamp
- timestampStart
- timestampEnd

Is it possible to calculate a "virtual" field "timeDiff" in kibana by calculating timestampEnd-timestampStart?  
I don't need to search by these fields, but aggregating on them would help.

Other familiar topic is, to convert for example a field which contains a value in seconds to hours to have a better overview in dashboards.

Is that possible? How?

Thanks, Andreas

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [January 31, 2017, 4:29pm UTC](https://discuss.elastic.co/t/kibana-5-1-possible-to-calculate-time-difference-and-place-it-in-a-field-in-kibana-at-runtime/73387/2 "2017-01-31T16:29:15Z")

</div>

hi @asp

You would use a scripted field for that.

My response here - to a similar question - has some links to resources to help you get started [Plot latency measure based on two time fields in an index](https://discuss.elastic.co/t/plot-latency-measure-based-on-two-time-fields-in-an-index/73244/2)

---

<div class="post-metadata">

**Author:** ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)\
**Post date:** [January 31, 2017, 4:35pm UTC](https://discuss.elastic.co/t/kibana-5-1-possible-to-calculate-time-difference-and-place-it-in-a-field-in-kibana-at-runtime/73387/3 "2017-01-31T16:35:46Z")

</div>

thanks for the fast response. I will take a deeper look

---

<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:** [February 28, 2017, 4:36pm UTC](https://discuss.elastic.co/t/kibana-5-1-possible-to-calculate-time-difference-and-place-it-in-a-field-in-kibana-at-runtime/73387/4 "2017-02-28T16:36:19Z")

</div>

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