# How to show timestamp difference between max and min in data table

**URL:** https://discuss.elastic.co/t/how-to-show-timestamp-difference-between-max-and-min-in-data-table/279347
**Category:** Elasticsearch
**Created:** [July 22, 2021, 6:51am UTC](https://discuss.elastic.co/t/how-to-show-timestamp-difference-between-max-and-min-in-data-table/279347 "2021-07-22T06:51:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![byun618](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/byun618/32/91962_2.png) [@byun618](https://discuss.elastic.co/u/byun618)
#### Post date: [July 22, 2021, 6:51am UTC](https://discuss.elastic.co/t/how-to-show-timestamp-difference-between-max-and-min-in-data-table/279347/1 "2021-07-22T06:51:41Z")

</div>

hello everyone

 ![스크린샷 2021-07-22 오후 3.45.47](https://us1.discourse-cdn.com/elastic/original/3X/4/d/4db080d215ef16f779aceec5e02d08925f6f48f4.png)  
 ![스크린샷 2021-07-22 오후 3.44.36](https://us1.discourse-cdn.com/elastic/original/3X/1/9/19b1a79790cda3f013e6a6c418c577558f2d573b.png)

i did show max timestamp and min stamp of each orderId. i want to show difference of them.

i did in dev tools with this query.

```auto
GET /toss-v2-confirmed-confirm_response/_search
{
 "aggs": {
    "group_orderId": {
      "terms": {
        "field": "orderId.keyword",
        "size": 10
      },
      "aggs": {
        "min_createdAt": {
          "min": {
            "field": "createdAt"
          }
        },
        "max_createdAt": {
          "max": {
            "field": "createdAt"
          }
        },
        "diff": {
          "bucket_script": {
            "buckets_path": {
              "min_createdAt": "min_createdAt",
              "max_createdAt": "max_createdAt"
            },
            "script": "params.max_createdAt - params.min_createdAt"
          }
        }
      }
    }
  } 
}

```

also, i did in TSVB as well.

 ![스크린샷 2021-07-22 오후 3.48.49](https://us1.discourse-cdn.com/elastic/original/3X/b/b/bbfbaa49e780bfcb807721aeca43119c3ab6796b.png)  
but, i want to show the difference in data table as well. is there any way?

---

<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: [August 19, 2021, 6:52am UTC](https://discuss.elastic.co/t/how-to-show-timestamp-difference-between-max-and-min-in-data-table/279347/2 "2021-08-19T06:52:15Z")

</div>

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