# Create Timerange

**URL:** <https://discuss.elastic.co/t/create-timerange/301015>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [March 30, 2022, 12:09am UTC](https://discuss.elastic.co/t/create-timerange/301015 "2022-03-30T00:09:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoncaloCarvalho](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/goncalocarvalho/32/103087_2.png) [@GoncaloCarvalho](https://discuss.elastic.co/u/GoncaloCarvalho)\
**Post date:** [March 30, 2022, 12:09am UTC](https://discuss.elastic.co/t/create-timerange/301015/1 "2022-03-30T00:09:55Z")

</div>

Greetings,

Was wondering if someone could throw at me an example of how to use the Timerange in the expression language?

I'm currently trying something of the likes:

| var\_set "timeToGo" value={timerange from="2022-03-29T23:56:25.129Z" to="2022-03-30T17:00:00.000Z"}

And it's throwing me an exception where the element is grayed out and there is no message popping up from said element.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![charlesfr.rey](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@charlesfr.rey](https://discuss.elastic.co/u/charlesfr.rey)\
**Post date:** [April 1, 2022, 5:42pm UTC](https://discuss.elastic.co/t/create-timerange/301015/2 "2022-04-01T17:42:58Z")

</div>

Hi,

As far as I can tell, it is related to the savedLens / savedMap / savedVisualization input parameters.

If your timerange is not static, you can pass such an object, and it will drive the time range of the embedded Kibana visualization.

```auto
var_set "timeToGo" value={timerange from="2022-03-20T23:56:25.129Z" to="2022-03-30T17:00:00.000Z"}
| savedMap id="..." center={mapCenter lat=47.56831 lon=7.53243 zoom=12.43} timerange={var name="timeToGo"}
| render

```

You can add this kind of saved object using the menu (+) Add element, and then Add from Kibana.

Looking at the code (kibana/x-pack/plugins/canvas), I don't see other uses of "timerange" outside these saved\* embedded objects.

Hope this helps.

---

<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 29, 2022, 5:43pm UTC](https://discuss.elastic.co/t/create-timerange/301015/3 "2022-04-29T17:43:57Z")

</div>

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