# Difference between Max timestamp and Minimum timstamp in kibana

**URL:** https://discuss.elastic.co/t/difference-between-max-timestamp-and-minimum-timstamp-in-kibana/84751
**Category:** Kibana
**Created:** [May 5, 2017, 3:32pm UTC](https://discuss.elastic.co/t/difference-between-max-timestamp-and-minimum-timstamp-in-kibana/84751 "2017-05-05T15:32:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![abhi1](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@abhi1](https://discuss.elastic.co/u/abhi1)
#### Post date: [May 5, 2017, 3:32pm UTC](https://discuss.elastic.co/t/difference-between-max-timestamp-and-minimum-timstamp-in-kibana/84751/1 "2017-05-05T15:32:17Z")

</div>

I have a log data where I have user activity getting logged in for a particular user on a particular timestamp. Now I was able to create a min and max of timestamp field for a particular user in a particular day. I wan to calculate a difference between the two (i.e. max timestamp field - min timestamp field for a particular day) to create a duration field. Could you please suggest how I can achieve this in Kibana

---

<div class="post-metadata">

### Author: ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)
#### Post date: [May 5, 2017, 4:52pm UTC](https://discuss.elastic.co/t/difference-between-max-timestamp-and-minimum-timstamp-in-kibana/84751/2 "2017-05-05T16:52:15Z")

</div>

> [@abhi1](#):
>
> I have a log data where I have user activity getting logged in for a particular user on a particular timestamp.

I'm assuming each document in your index looks something like this:

```auto
{
  "username": "X",
  "timestamp": YYYYMMDD...
}

```

> [@abhi1](#):
>
> Now I was able to create a min and max of timestamp field for a particular user in a particular day.

How are you creating the min and the max? Are you storing them somewhere in Elasticsearch?

---

<div class="post-metadata">

### Author: ![abhi1](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@abhi1](https://discuss.elastic.co/u/abhi1)
#### Post date: [May 5, 2017, 5:19pm UTC](https://discuss.elastic.co/t/difference-between-max-timestamp-and-minimum-timstamp-in-kibana/84751/3 "2017-05-05T17:19:24Z")

</div>

Yes, my data looks like the way u have mentioned in your post.

I am calculating the Max and Min of timestamp in kibana by using the max/min of metric aggregation ; i have not created any separate field in ES

---

<div class="post-metadata">

### Author: ![abhi1](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@abhi1](https://discuss.elastic.co/u/abhi1)
#### Post date: [May 9, 2017, 2:41pm UTC](https://discuss.elastic.co/t/difference-between-max-timestamp-and-minimum-timstamp-in-kibana/84751/4 "2017-05-09T14:41:08Z")

</div>

Any solution for this???

---

<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: [June 6, 2017, 2:47pm UTC](https://discuss.elastic.co/t/difference-between-max-timestamp-and-minimum-timstamp-in-kibana/84751/5 "2017-06-06T14:47:00Z")

</div>

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