# Visualize day between two dates on kibana

**URL:** <https://discuss.elastic.co/t/visualize-day-between-two-dates-on-kibana/120452>\
**Category:** Kibana\
**Created:** [February 19, 2018, 12:37pm UTC](https://discuss.elastic.co/t/visualize-day-between-two-dates-on-kibana/120452 "2018-02-19T12:37:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timotius\_Pamungkas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timotius_pamungkas/32/42522_2.png) [@Timotius\_Pamungkas](https://discuss.elastic.co/u/Timotius_Pamungkas)\
**Post date:** [February 19, 2018, 12:37pm UTC](https://discuss.elastic.co/t/visualize-day-between-two-dates-on-kibana/120452/1 "2018-02-19T12:37:51Z")

</div>

I have date with following fields

```auto
    ...
    ...
    branch_id: 909
    agent_id: 909A01234
    first_call_date: date A, can be empty (no call made yet)
    final_call_date: date B, can be empty (no call made yet)
    ...
    ...

```

I want to visualize min, max, and average(days between **first\_call\_date** and **final\_call\_date** , group by branch. I'm thinking of having line chart where x axis is branch\_id. The question is: how can I calculate days between those two days? I don't see any math function during visualization creation.

Thank you

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [February 19, 2018, 2:42pm UTC](https://discuss.elastic.co/t/visualize-day-between-two-dates-on-kibana/120452/2 "2018-02-19T14:42:48Z")

</div>

Hi,

You can use scripted fields here. Write a script to calculate the days between those two days - add it to a field and use that in visualization.

 ![scripted_field](https://us1.discourse-cdn.com/elastic/original/3X/8/d/8d9f2af0a00c4a6397f76013b9aef6cc772d71d1.jpg)

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![Timotius\_Pamungkas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timotius_pamungkas/32/42522_2.png) [@Timotius\_Pamungkas](https://discuss.elastic.co/u/Timotius_Pamungkas)\
**Post date:** [February 23, 2018, 4:44am UTC](https://discuss.elastic.co/t/visualize-day-between-two-dates-on-kibana/120452/3 "2018-02-23T04:44:55Z")

</div>

Thanks. I tried this, but does not success  
**doc['final\_call\_date'].value-doc['first\_call\_date'].value**

Is there something I miss?

```auto
Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse date field [__missing__] with format [strict_date_optional_time||epoch_millis]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"logstash-btpn-leads-2018.08","node":"e80Fgn8CRzSBR093BcXl2A","reason":{"type":"parse_exception","reason":"failed to parse date field [__missing__] with format [strict_date_optional_time||epoch_millis]","caused_by":{"type":"illegal_argument_exception","reason":"Parse failure at index [0] of [__missing__]"}}}]},"status":400}
    at http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:712490
    at Function.Promise.try (http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:503537)
    at http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:502925
    at Array.map (<anonymous>)
    at Function.Promise.map (http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:502883)
    at callResponseHandlers (http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:712068)
    at http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:701418
    at processQueue (http://consul1.bfi.co.id/kibana/bundles/vendors.bundle.js?v=16588:58:132456)
    at http://consul1.bfi.co.id/kibana/bundles/vendors.bundle.js?v=16588:58:133349
    at Scope.$digest (http://consul1.bfi.co.id/kibana/bundles/vendors.bundle.js?v=16588:58:144239)

```

---

<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:** [March 23, 2018, 4:45am UTC](https://discuss.elastic.co/t/visualize-day-between-two-dates-on-kibana/120452/4 "2018-03-23T04:45:51Z")

</div>

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