Diff between two date fields in kibana

A document with several date fields.
How can I determine the delta of time in days, for example, between several dates in this document?
Dates can be different years, i.e. It is necessary to minus the older date.
For example, use doc['date1'].date.dayOfYear - doc['date0'].date.dayOfYear a negative number is obtained. Because these dates are from different years. How to get the difference?

Try calculating the difference using doc[date1].date.millis or doc[date1].value and then converting the number into the value you want (e.g. days).

This stack overflow gives some more details that I think will help you: https://stackoverflow.com/questions/32658639/how-to-calculate-difference-between-two-datetime-in-elasticsearch

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