# How to dynamically pass range query variables

**URL:** <https://discuss.elastic.co/t/how-to-dynamically-pass-range-query-variables/245647>\
**Category:** Elasticsearch\
**Created:** [August 19, 2020, 4:08pm UTC](https://discuss.elastic.co/t/how-to-dynamically-pass-range-query-variables/245647 "2020-08-19T16:08:53Z")\
**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 19, 2020, 4:08pm UTC](https://discuss.elastic.co/t/how-to-dynamically-pass-range-query-variables/245647/1 "2020-08-19T16:08:53Z")

</div>

hi  
We need to pass dynamic values into the filter range query within `watcher`, using a "painless" script. something like below

```auto
"filter": [ 
 {
   "range": {
      "@timestamp": {
         "lte": "now-{{dynamicValueLte}}",
         "gte": "now-{{dynamicValueGte}}"
        }
     }
   }
 }
]

```

the aim is to execute logic for a time range dynamically based on a configuration/json  
have anyone encountered or fixed similar issue?

---

<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 16, 2020, 4:08pm UTC](https://discuss.elastic.co/t/how-to-dynamically-pass-range-query-variables/245647/2 "2020-09-16T16:08:58Z")

</div>

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