# How to Access Kibana time range (timepicker) in a painless script

**URL:** <https://discuss.elastic.co/t/how-to-access-kibana-time-range-timepicker-in-a-painless-script/326871>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [March 2, 2023, 3:31pm UTC](https://discuss.elastic.co/t/how-to-access-kibana-time-range-timepicker-in-a-painless-script/326871 "2023-03-02T15:31:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyannea](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gyannea](https://discuss.elastic.co/u/gyannea)\
**Post date:** [March 2, 2023, 3:31pm UTC](https://discuss.elastic.co/t/how-to-access-kibana-time-range-timepicker-in-a-painless-script/326871/1 "2023-03-02T15:31:19Z")

</div>

When making a search for documents that have a time stamp the user can specify a time range over which the search will be done. It looks like this in the search request:

```auto
        {
          "range": {
            "date": {
              "format": "strict_date_optional_time",
              "gte": "2023-02-01T05:00:00.000Z",
              "lte": "2023-03-02T15:11:30.784Z"
            }
          }
        }

```

I have a painless script in this search that does some computations on a time field. To do some further analysis I need to know the time range of the search.

How could I get these same range values so I could use them in my painless script?

I am stuck with version 7.1.1.

I have just found out this is called 'timepicker' and this issue was brought up some years ago

> [@Use timepicker value for script](https://discuss.elastic.co/t/use-timepicker-value-for-script/93678):
>
> Hi! Thank you for your works! Can I use timepicker value from kibana dashboard for the script? I used this kind of script before. doc['date1'].value-doc['date'].value What I want to do is that using timepicker value(from dashboard) for calculating scripted field dynamically. doc['date1'].value - timepicker value Thanks. HJ

and at the time it was not possible. An enhancement request was made. Did it happen and if so where are the docs?

---

<div class="post-metadata">

**Author:** ![gyannea](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gyannea](https://discuss.elastic.co/u/gyannea)\
**Post date:** [March 6, 2023, 10:17am UTC](https://discuss.elastic.co/t/how-to-access-kibana-time-range-timepicker-in-a-painless-script/326871/2 "2023-03-06T10:17:26Z")

</div>

Migrated to 7.10.2 and I still find no means of accessing the timepicker values.

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [March 7, 2023, 3:50pm UTC](https://discuss.elastic.co/t/how-to-access-kibana-time-range-timepicker-in-a-painless-script/326871/3 "2023-03-07T15:50:55Z")

</div>

Hi @gyannea. It looks like an [enhancement request](https://github.com/elastic/kibana/issues/13023) was made a while back, but it was closed due to inactivity. I suggest adding a comment detailing your needs and re-opening the 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:** [April 4, 2023, 3:51pm UTC](https://discuss.elastic.co/t/how-to-access-kibana-time-range-timepicker-in-a-painless-script/326871/4 "2023-04-04T15:51:30Z")

</div>

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