# Two different date fields want to check is gte or lte

**URL:** <https://discuss.elastic.co/t/two-different-date-fields-want-to-check-is-gte-or-lte/121487>\
**Category:** Kibana\
**Created:** [February 26, 2018, 1:04pm UTC](https://discuss.elastic.co/t/two-different-date-fields-want-to-check-is-gte-or-lte/121487 "2018-02-26T13:04:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Praveen\_M](https://avatars.discourse-cdn.com/v4/letter/p/6bbea6/32.png) [@Praveen\_M](https://discuss.elastic.co/u/Praveen_M)\
**Post date:** [February 26, 2018, 1:04pm UTC](https://discuss.elastic.co/t/two-different-date-fields-want-to-check-is-gte-or-lte/121487/1 "2018-02-26T13:04:02Z")

</div>

Hi All !...

Am new to Elasticsearch 6.2.1 and Kibana 6.2.1. Now am working on scripted Field in kibana.  
I have two different date fields in indices like (resolved\_on and resolve\_due\_by) i want check the condition if resolved\_on is lessThan or equalTo resolve\_due\_bye. I tried some scripted query that are shown below

```
doc['resolved_on'] <= doc['resolve_due_by'] <!-- This not working -->

```

The below code is working now. I don't know whether it's correct way or not to proceed with two different dates.

```
((doc['resolved_on'].date.dayOfYear <= doc['resolve_due_by'].date.dayOfYear) && (doc['resolved_on'].date.millisOfDay <= doc['resolve_due_by'].date.millisOfDay)) 

```

Please can anyone help me this ?

Thank you

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [February 27, 2018, 11:06pm UTC](https://discuss.elastic.co/t/two-different-date-fields-want-to-check-is-gte-or-lte/121487/2 "2018-02-27T23:06:56Z")

</div>

Your solution is what I would recommend. Here is the date field API that is exposed: [https://www.elastic.co/guide/en/elasticsearch/reference/6.2/modules-scripting-expression.html#\_date\_field\_api](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/modules-scripting-expression.html#_date_field_api)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 27, 2018, 11:07pm UTC](https://discuss.elastic.co/t/two-different-date-fields-want-to-check-is-gte-or-lte/121487/3 "2018-03-27T23:07:19Z")

</div>

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