# Date fields comparison

**URL:** <https://discuss.elastic.co/t/date-fields-comparison/272724>\
**Category:** Kibana\
**Created:** [May 11, 2021, 4:14pm UTC](https://discuss.elastic.co/t/date-fields-comparison/272724 "2021-05-11T16:14:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 11, 2021, 11:04pm UTC](https://discuss.elastic.co/t/date-fields-comparison/272724/2 "2021-05-11T23:04:27Z")

</div>

There are dozens of examples out there.  
Here are a couple of them --\>

> [@Calculate Difference between 2 Dates in Scipted Field](https://discuss.elastic.co/t/calculate-difference-between-2-dates-in-scipted-field/153129):
>
> Hi All, I am trying to create a new scripted field by calculating the difference(in seconds) between 2 date in the following format ` October 15th 2018, 22:15:27.823 The two fields I am using are start\_time and end\_time. I have tried various method covering both Painless and expression as language. Every time I try I get different error. Example:- if(!doc['end\_time'].empty) { return doc['end\_time'].value - doc['start\_time'].value } Error it gave is:- "caused\_by":{"type":"parse\_except…

> <https://stackoverflow.com/questions/31673468/kibana-time-delta-between-two-fields>

> [@Kibana painless- Difference in dates in days](https://discuss.elastic.co/t/kibana-painless-difference-in-dates-in-days/169201):
>
> I have two date fields - Date1 and Date2, both are in date format I want to calculate days between the two dates. I tried doc['date2'].value - doc['date1'].value, this is not giving the expected return value

---

_[View the full topic](https://discuss.elastic.co/t/date-fields-comparison/272724)._
