[scripted field] convert String date to timestamp

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'
}

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

1 Like

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