# Use value of a field as timezone in range query

**URL:** <https://discuss.elastic.co/t/use-value-of-a-field-as-timezone-in-range-query/231347>\
**Category:** Elasticsearch\
**Created:** [May 6, 2020, 1:27pm UTC](https://discuss.elastic.co/t/use-value-of-a-field-as-timezone-in-range-query/231347 "2020-05-06T13:27:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quang\_D\_Tr\_n](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quang_d_tr_n/32/54722_2.png) [@Quang\_D\_Tr\_n](https://discuss.elastic.co/u/Quang_D_Tr_n)\
**Post date:** [May 6, 2020, 1:27pm UTC](https://discuss.elastic.co/t/use-value-of-a-field-as-timezone-in-range-query/231347/1 "2020-05-06T13:27:17Z")

</div>

My index has two fields: `"local_time": "2020-04-28T11:00:52.000-0500"` as date and `"timezone": "America/Bogota"` as string.  
The `local_time` stores various timezones. I want to search for the same time range but in different timezones.

How could I use the value of `timezone` in the range query? I have checked but range query does not have painless script guie.

```auto
                   "range": {
                        "local_time": {
                            "gt": "2020-01-13T00:00:00",
                            "lt": "2020-01-19T23:59:59", 
                            "time_zone": {{timezone value here}},
                            "format": "date_hour_minute_second"
                        }
                    

```

---

<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:** [June 3, 2020, 1:27pm UTC](https://discuss.elastic.co/t/use-value-of-a-field-as-timezone-in-range-query/231347/2 "2020-06-03T13:27:19Z")

</div>

Closed on June 3, 2020, 1:27pm UTC

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