Kibana 7.5.1 - calculating user's AGE by using Scripted Field

hey guys,

this is my script (found it online), unfortunately it keeps returning "0".

Field Type:

return Period.between (
doc['@timestamp'].value.toLocalDate(), Instant.ofEpochMilli(System.currentTimeMillis()).atZone(doc['@timestamp'].value.getZone()).toLocalDate() ).getYears()

do you have any idea why?

This is simpler way of figuring out what you want to find out (basically the number of years between current date and timestamp).

return System.currentTimeMillis() - doc["@timestamp"].value.getMillis()

And change the format to Duration and it will show it in years as well.

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