# Using "TimeTo" in JSON to set panel time range does not work

**URL:** <https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482>\
**Category:** Grafana\
**Created:** [June 4, 2021, 9:33am UTC](https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482 "2021-06-04T09:33:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick89](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@patrick89](https://community.grafana.com/u/patrick89)\
**Post date:** [June 4, 2021, 9:33am UTC](https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482/1 "2021-06-04T09:33:12Z")

</div>

Hi,

I try to set an individual panel time range via JSON.

I found the option “TimeFrom”, where I can set the different time range parameters (for example: 20h, now-10h …). That works well!

But If I set the option “TimeTo” to define the end time of my panel, everything I fill in does NOT work. So what could I do? Or is there an other option to define the end date of the panel (instead of “TimeTo”).

Here my example:

“timeFrom”: “now-20h”,  
“timeTo”: “now-10h”,  
“title”: “$filter\_description”,  
“type”: “timeseries”,  
“timeShift”: null,  
“datasource”: null

And is there a way to set instead of the relative parameter “now-20h” an absolute parameter, for example “2021-03-11 12:09:41.340”? I tried the absolute date in option “TimeFrom”, but that does not work. On the other hand, If I set the absolute date in dashboard options “FROM” and “TO” (manuel time range filter) that DOES work.

Thanks for help.  
Greetings  
Patrick

---

<div class="post-metadata">

**Author:** ![patrick89](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@patrick89](https://community.grafana.com/u/patrick89)\
**Post date:** [June 8, 2021, 9:51am UTC](https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482/2 "2021-06-08T09:51:02Z")

</div>

Can anyone help?

Thanks!  
Patrick

---

<div class="post-metadata">

**Author:** ![svetb](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/svetb/32/3307_2.png) [@svetb](https://community.grafana.com/u/svetb)\
**Post date:** [June 8, 2021, 10:12am UTC](https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482/3 "2021-06-08T10:12:42Z")

</div>

If you want a range starting at now-20h and ending at now-10h you can set the following in the UI:

 ![Screen Shot 2021-06-08 at 12.09.52 PM](https://us1.discourse-cdn.com/grafana/original/3X/9/f/9f012cff97f46f940b42e893595e712b6348a9b6.png)  
I haven’t checked what this corresponds to in the dashboard JSON, but perhaps you can share.

Also, I don’t think that absolute timestamps can he used for this. If you do want absolute timestamps then I suppose you can just hardcode those in your query?

---

<div class="post-metadata">

**Author:** ![patrick89](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@patrick89](https://community.grafana.com/u/patrick89)\
**Post date:** [June 8, 2021, 11:18am UTC](https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482/4 "2021-06-08T11:18:35Z")

</div>

Hi thanks for help!

I have already tried it. If I do it this way, I am not able to zoom into a specific timerange, if I need to. Because there will be always a Time shift to the range I selected.

How can I hardcode the absolute timestamps in my query?

Now my query looks like:

SELECT Timestamp as time, Value as value, ChannelId as metric  
FROM DataloggerMeasuredValue  
WHERE Unit LIKE N’%V%’ AND MeasurementIdentifier in (’${filter\_measurementIdentifier}’)

Thanks!  
Patrick

---

<div class="post-metadata">

**Author:** ![svetb](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/svetb/32/3307_2.png) [@svetb](https://community.grafana.com/u/svetb)\
**Post date:** [June 8, 2021, 1:55pm UTC](https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482/5 "2021-06-08T13:55:59Z")

</div>

Sorry I think I misled you with my comment about hardcoding in the query. That would only change what data is queried, not the actual time range that’s shown in the panel. So unfortunately I don’t have an idea of how to set the time period of a panel to a fixed absolute range.

> [@patrick89](#):
>
> I have already tried it. If I do it this way, I am not able to zoom into a specific timerange, if I need to. Because there will be always a Time shift to the range I selected.

Right…well I guess the idea of applying an override is that the time period you select overrides (with a specific offset) the dashboard time range that you select otherwise. I’m not sure if a different behavior is supported - though I’d also be up-front about the fact that I haven’t really delved into this (e.g. I’m not sure whether further options are possible through editing the JSON).

---

<div class="post-metadata">

**Author:** ![patrick89](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@patrick89](https://community.grafana.com/u/patrick89)\
**Post date:** [June 9, 2021, 5:37am UTC](https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482/6 "2021-06-09T05:37:52Z")

</div>

Thanks for information!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [June 4, 2022, 9:34am UTC](https://community.grafana.com/t/using-timeto-in-json-to-set-panel-time-range-does-not-work/48482/7 "2022-06-04T09:34:00Z")

</div>

This topic was automatically closed after 365 days. New replies are no longer allowed.
