Problem in difference between two dates

Hello ,

I have problem with this script :

if ( doc['entities.status'].value == doc['entities.statusesInformation.statusName'].value ) {
return doc['entities.executionDate'].date - doc['entities.creationDate'].date ;
}

When i execute it, i got this error :

lang":"painless","caused_by":{"type":"class_cast_exception","reason":"Cannot apply [-] operation to types [org.joda.time.MutableDateTime] and [org.joda.time.MutableDateTime]."}}}]},"status":500}

Thank you for your helps.

As the error states, you can use that operator on the date.

Here are supported date functions: https://www.elastic.co/guide/en/elasticsearch/reference/6.2/modules-scripting-expression.html#_date_field_api

1 Like

Thank you for your reply.

I solved the problem with date in painless but i have another error ( null pointer exception ) with this :

doc['entities.statusesInformation.statusName'].value )

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