# Data Dif @timestamp

**URL:** <https://discuss.elastic.co/t/data-dif-timestamp/222099>\
**Category:** Kibana\
**Created:** [March 4, 2020, 2:06pm UTC](https://discuss.elastic.co/t/data-dif-timestamp/222099 "2020-03-04T14:06:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcelosouzadias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcelosouzadias/32/63810_2.png) [@marcelosouzadias](https://discuss.elastic.co/u/marcelosouzadias)\
**Post date:** [March 4, 2020, 2:06pm UTC](https://discuss.elastic.co/t/data-dif-timestamp/222099/1 "2020-03-04T14:06:07Z")

</div>

Hello

I have an index containing an id and @timestamp.

![image](https://us1.discourse-cdn.com/elastic/original/3X/b/e/be2e0d8254ed2d5376244acaff06a1397a375231.png)

I need to make the difference between the first @timestamp and the last @timestamp.

Is it possible to perform this calculation in Script Fields?

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [March 12, 2020, 12:18pm UTC](https://discuss.elastic.co/t/data-dif-timestamp/222099/2 "2020-03-12T12:18:46Z")

</div>

It can be done using the Math aggregation in TSVB the easiest. Create a metric for Max, one for Min, group them by that ID and then do a Math where you do the difference.

---

<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:** [April 9, 2020, 12:18pm UTC](https://discuss.elastic.co/t/data-dif-timestamp/222099/3 "2020-04-09T12:18:54Z")

</div>

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