Add New field by Comparing Date

Hi,
I am using Kibana v7.17 where I am trying to create new calculated field by comparing the date present in the existing field with hardcoded date.
For e.g. if(doc['trans_date'].value >= "2021-02-15" {emit("FY 2021"}

But here getting error that cannot compare Date with string. How to convert "2021-02-15" to Date type?

Check this page:

This code snippet worked for me:

String datetime = '2021-02-15T00:00:00Z';
ZonedDateTime zdt = ZonedDateTime.parse(datetime);

ZonedDateTime zdtTo = doc['timestamp'].value;

if ( zdt.isAfter(zdtTo)){
    emit('after');
} else {
    emit('before');
}

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