Datefields time difference in scripted field produce zero always

Hi,

I want to find out the difference between two date fields using scripted value. However, the result is always coming as zero. I am using painless as the language (tried with expression also, but still result is zero). I am using the following code in scripted field

doc['time1'].value.getMillis() - doc['time2'].value.getMillis()

Both 'time1' and 'time2' are date fields as shown in Discover tab.

Hi Pranamesh,

In case you need to do date math, you will have to cast the field values to date types in Painless. Check some examples in the article:
Elastic: Using Painless in Kibana scripted fields By Tanya Bragin on Elastic web site

Steve

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