# Timestamp Difference between two fields

**URL:** <https://discuss.elastic.co/t/timestamp-difference-between-two-fields/138169>\
**Category:** Kibana\
**Created:** [July 2, 2018, 10:05am UTC](https://discuss.elastic.co/t/timestamp-difference-between-two-fields/138169 "2018-07-02T10:05:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berin](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@Berin](https://discuss.elastic.co/u/Berin)\
**Post date:** [July 2, 2018, 10:05am UTC](https://discuss.elastic.co/t/timestamp-difference-between-two-fields/138169/1 "2018-07-02T10:05:37Z")

</div>

Hi Team,

I am new to this Elastic search/ Kibana , we need to calculate the timestamp difference between two fields, In fact i even tired with scripted fields , using painless scripts "doc['startTime'].value - doc['EndTime'].value" , it dint work. Also whenever i use scripted field and select the index , under discover tab , could see a warning msg **Courier Fetch 2 0f 5 shards failed"**. Appreciate your help

Thanks,  
Berin.

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [July 2, 2018, 4:26pm UTC](https://discuss.elastic.co/t/timestamp-difference-between-two-fields/138169/2 "2018-07-02T16:26:45Z")

</div>

> [@Berin](#):
>
> Courier Fetch 2 0f 5 shards failed"

This is likely an indication that there's a problem with your cluster's health. Without knowing more about your cluster, there's not much more that can be said. Can you provide more details - version, steps, screenshots, logs.

Thanks  
Rashmi

---

<div class="post-metadata">

**Author:** ![Berin](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@Berin](https://discuss.elastic.co/u/Berin)\
**Post date:** [July 10, 2018, 6:58am UTC](https://discuss.elastic.co/t/timestamp-difference-between-two-fields/138169/3 "2018-07-10T06:58:48Z")

</div>

Hi Rashmi,

Thanks for your email.

Details:-

Version:- elasticsearch-6.2.3 / kibana-6.2.3  
Steps for scripted scripts:-  
select Language :- painless  
Type:- Number  
Format : Duration (seconds, human readable)  
script :- doc['FinalloadCompletehappened'].value -  
doc['RequestReceivedbyLoadManager'].value

Also i have attached few screenshots for your reference

 ![indices](https://us1.discourse-cdn.com/elastic/original/3X/2/1/215eee341efb8fb978272934db2fa45865371db5.png) ![Shards%20Failed](https://us1.discourse-cdn.com/elastic/original/3X/3/9/3966cf5195b1fdec41628719deea15f1ec0b2a5e.png) ![Documents](https://us1.discourse-cdn.com/elastic/original/3X/3/2/32bf8324b98fcc740469aa941bf9ea92784c862d.png)

Regards,  
Berin

---

<div class="post-metadata">

**Author:** ![rashmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi/32/16391_2.png) [@rashmi](https://discuss.elastic.co/u/rashmi)\
**Post date:** [July 10, 2018, 3:20pm UTC](https://discuss.elastic.co/t/timestamp-difference-between-two-fields/138169/4 "2018-07-10T15:20:47Z")

</div>

Hi Berin,

The error message seems misleading. Its a generic your script failed message, there should be more info in the network tab in the browser. If I had to take a guess this script needs to make sure both fields exist before checking for .value !doc[field].empty.

Cheers  
Rashmi.

---

<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 7, 2018, 3:21pm UTC](https://discuss.elastic.co/t/timestamp-difference-between-two-fields/138169/5 "2018-08-07T15:21:01Z")

</div>

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