How to do time math in script field

Hi, I want to do some time math in script field of Kibana. Now I have a field called startdatetime with the data type of date, and a field called runtime with the data type of number, how can i sum them up and return a new field with the type of date? Please help me . Looking forward to your reply, THANKS!

Hi @Echo_yu

Painless easily supports such manipulations:
Try using something like this in your scripted field:

Instant.ofEpochMilli(doc['startdatetime'].value.getMillis() + doc['runtime'].value)

Good luck,
Liza
`

It works correctly!Thank you so much! :smiling_face_with_three_hearts:

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