[scripted field] convert String date to timestamp


(HJ Shin) #1

Hi.

I am trying to calculate dates in scripted field.

If I want to calculated between elasticsearch field and date string, what should I do?

I think I need to convert string type date to timestamp.
What is the way to do that?

if('2017-01-01'-doc['WK_DT'].value > 0){
return '2017-01-01'-doc['WK_DT'].value
}else{
return '-1'
}


How do I subtract two timestamps in VisualBuilder
(Thomas Neirynck) #2

hi @Hyojoung_Shin,

to learn more about the date-maths supported by Painless, check out this https://www.elastic.co/blog/using-painless-kibana-scripted-fields.

more detailed documentation is here: https://www.elastic.co/guide/en/elasticsearch/reference/5.0/modules-scripting-expression.html#_date_field_api


(system) #3

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