# Calculate elapsed time in Kibana?

**URL:** <https://discuss.elastic.co/t/calculate-elapsed-time-in-kibana/316575>\
**Category:** Kibana\
**Created:** [October 13, 2022, 7:56pm UTC](https://discuss.elastic.co/t/calculate-elapsed-time-in-kibana/316575 "2022-10-13T19:56:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 13, 2022, 8:35pm UTC](https://discuss.elastic.co/t/calculate-elapsed-time-in-kibana/316575/2 "2022-10-13T20:35:11Z")

</div>

Hi @TXBigDawg1836 Welcome to the community

Yup add a runtime field to the Data View

here is the code

```auto
long datenow = new Date().getTime();
long datewas = doc['@timestamp'].value.getMillis();
emit (datenow - datewas);

```

Create / Set the Field

 ![Screen Shot 2022-10-13 at 1.23.42 PM](https://us1.discourse-cdn.com/elastic/original/3X/5/d/5d4e39d84e0916b69d05e71e5ff9fc6f12af9677.jpeg)

Chose your format....

 ![Screen Shot 2022-10-13 at 1.23.54 PM](https://us1.discourse-cdn.com/elastic/original/3X/d/6/d639a357175496391ed02c46c4a651d556eb7247.png)

In Discover

 ![Screen Shot 2022-10-13 at 1.34.19 PM](https://us1.discourse-cdn.com/elastic/original/3X/8/e/8e1a8f1a08a42c9ad880294e548ee361763cac18.jpeg)

Now Table...

 ![Screen Shot 2022-10-13 at 1.26.49 PM](https://us1.discourse-cdn.com/elastic/original/3X/d/f/dfde664fb2d3fdd19abf952fec49aee001218867.png)

---

_[View the full topic](https://discuss.elastic.co/t/calculate-elapsed-time-in-kibana/316575)._
