How to calculate Date difference using scripted fields

Hello Team,

I have a use case to take the difference between two dates in the form of year,month,day,hour,minute,second format.

for example

10-mar-2019 10:00:00 - 09-mar-2019 10:00:00 would be = 0 years,0 month,1 day, 0 Hrs,0 Mins,0 Sec.

I was able to find the diff using scripted field (painless script)

doc['date1'].date.toMillis() - doc['date2'].date.toMillis()

is there any way to convert miliseconds to above format.

Thank you for your help and support.

Thank You,
Aditya

1 Like

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