# Date comparison in painless script

**URL:** <https://discuss.elastic.co/t/date-comparison-in-painless-script/224854>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [March 24, 2020, 1:57pm UTC](https://discuss.elastic.co/t/date-comparison-in-painless-script/224854 "2020-03-24T13:57:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![satish\_Kumar087](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/satish_kumar087/32/64983_2.png) [@satish\_Kumar087](https://discuss.elastic.co/u/satish_Kumar087)\
**Post date:** [March 24, 2020, 1:57pm UTC](https://discuss.elastic.co/t/date-comparison-in-painless-script/224854/1 "2020-03-24T13:57:26Z")

</div>

Hey there,

I am new to Elastic search. I am trying to update a record by using \_update\_by\_query API, by using a painless script as below.

```auto
"script": {
    "source": "if(ctx._source.global_cro_dist_due < params.current){ctx._source.oud_modified_by = 'SYSTEM2'}",
    "lang": "painless",
    "params" : {
      "current" : "2020-03-24T13:32:00"
    }
}

```

But, the above script is giving me below error.

```auto
"caused_by": {
      "type": "illegal_argument_exception",
      "reason": "field [java.lang.System, currentTimeInMillis] not found"
}

```

Any thought or solution is most welcome and appreciated.

Note: Basically, i am stuck in comparing dates in if clause. Please help me to resolve this.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 24, 2020, 4:30pm UTC](https://discuss.elastic.co/t/date-comparison-in-painless-script/224854/2 "2020-03-24T16:30:58Z")

</div>

That is a weird one, given the fact, that you are not calling `currentTimeMillis` in your script.

First, which Elasticsearch version is this on?

Second, can you create a minimal reproducible example, that contains index creation/mapping, document indexing and the full script call, so one could reproduce locally?

Thank you!

---

<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:** [April 21, 2020, 4:31pm UTC](https://discuss.elastic.co/t/date-comparison-in-painless-script/224854/3 "2020-04-21T16:31:12Z")

</div>

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