# Painless: Any easy way to define dates like now-1d, now-2d

**URL:** <https://discuss.elastic.co/t/painless-any-easy-way-to-define-dates-like-now-1d-now-2d/280773>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [August 9, 2021, 8:21am UTC](https://discuss.elastic.co/t/painless-any-easy-way-to-define-dates-like-now-1d-now-2d/280773 "2021-08-09T08:21:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelk](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kelk](https://discuss.elastic.co/u/kelk)\
**Post date:** [August 9, 2021, 8:21am UTC](https://discuss.elastic.co/t/painless-any-easy-way-to-define-dates-like-now-1d-now-2d/280773/1 "2021-08-09T08:21:56Z")

</div>

We have a painless script to compare a logic before a date. Currently the user have to enter epoch value into the params, but was checking if you guys already have a script or logic, so we can use the "range" notations in the parameters?

```auto
        "my_hostnames": {
          "bucket_selector": {
            "buckets_path": {
              "time_max": "time_max"
            },
            "script": """
            params.time_max > 1628294400000L
            """
          }
        }

```

So i.e. time of Yesterday (1 day before) and we could have entered that as `now-1d/d` format and is there a way we could do that using painless?

So ultimately we are looking for a simplified usage for end-user

```auto
            "script": """
            params.time_max > now-1d/d
            """

```

---

<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:** [September 6, 2021, 8:22am UTC](https://discuss.elastic.co/t/painless-any-easy-way-to-define-dates-like-now-1d-now-2d/280773/2 "2021-09-06T08:22:23Z")

</div>

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