# Date math in Kibana 5

**URL:** <https://discuss.elastic.co/t/date-math-in-kibana-5/67112>\
**Category:** Kibana\
**Created:** [November 24, 2016, 1:34pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112 "2016-11-24T13:34:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@aros](https://discuss.elastic.co/u/aros)\
**Post date:** [November 24, 2016, 1:34pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/1 "2016-11-24T13:34:00Z")

</div>

Hi,

probably a classic and simple to answer, but as I found quite different answers to several questions about date math in Kibana I want to ask here if and how date math is supported in the current 5.0 version of kibana.  
Basicly I want to do e.g range queries on a date field, something like @timestamp:[NOW/DAY TO NOW] or @timestamp[NOW-7DAY TO NOW]. I found some examples like this but they aint work for me. Is that possible in kibana at the moment and if so how?

Thanks,  
Andrej

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [November 24, 2016, 1:42pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/2 "2016-11-24T13:42:57Z")

</div>

You could try to use the [timepicker](https://www.elastic.co/guide/en/kibana/current/set-time-filter.html) to do that. You can define relative time ranges. Let me know if this answers your question.

regards, Peter

---

<div class="post-metadata">

**Author:** ![aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@aros](https://discuss.elastic.co/u/aros)\
**Post date:** [November 24, 2016, 1:55pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/3 "2016-11-24T13:55:24Z")

</div>

Hi Peter,

thanks for your fast answer, but no, it doesnt solve my problem. I want to do it query wise and independent from timepicker. In a dashboard timepicker affects all visualizations, if I e.g have a metric that should display todays values this is not useful, because it will not be today but what timepicker selects. A query @timestamp[NOW/DAY TO NOW] on a pattern without events will always show only todays values, no matter what other visualizations do.

Regards,  
Andrej

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [November 24, 2016, 2:20pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/4 "2016-11-24T14:20:12Z")

</div>

this seems to work well `@timestamp:[now-1d TO now]`

---

<div class="post-metadata">

**Author:** ![aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@aros](https://discuss.elastic.co/u/aros)\
**Post date:** [November 24, 2016, 2:27pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/5 "2016-11-24T14:27:32Z")

</div>

Trying this on a @timestamp field with mapping type date I am getting: Error: Request to Elasticsearch failed: {"error":{"root\_cause":[{"type":"parse\_exception","reason":"could not read the current timestamp"}] ...

What mapping are you using for your field? Anything I have to enable in kibana or elasticsearch config?

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [November 24, 2016, 2:30pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/6 "2016-11-24T14:30:25Z")

</div>

```auto
 "@timestamp": {
            "type": "date"
          },

```

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [November 24, 2016, 2:30pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/7 "2016-11-24T14:30:47Z")

</div>

default install of elasticsearch 5.0.1 and kibana 5.0.1 with makelogs data

---

<div class="post-metadata">

**Author:** ![aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@aros](https://discuss.elastic.co/u/aros)\
**Post date:** [November 24, 2016, 2:41pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/8 "2016-11-24T14:41:39Z")

</div>

Ok, a bit more stacktrace:

Error: Request to Elasticsearch failed: {"error":{"root\_cause":[{"type":"parse\_exception","reason":"could not read the current timestamp"}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query\_fetch","grouped":true,"failed\_shards":[{"shard":0,"index":"indexname","node":"nodeidhere","reason":{"type":"parse\_exception","reason":"could not read the current timestamp","caused\_by":{"type":"illegal\_argument\_exception","reason":"features that prevent cachability are disabled on this context"}}}],"caused\_by":{"type":"parse\_exception","reason":"could not read the current timestamp","caused\_by":{"type":"illegal\_argument\_exception","reason":"features that prevent cachability are disabled on this context"}}},"status":400}

I am running 5.0.0. May be this is related to [https://github.com/elastic/elasticsearch/issues/21457](https://github.com/elastic/elasticsearch/issues/21457) ? I will try to run 5.0.1.

---

<div class="post-metadata">

**Author:** ![aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@aros](https://discuss.elastic.co/u/aros)\
**Post date:** [November 24, 2016, 3:25pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/9 "2016-11-24T15:25:48Z")

</div>

This is indeed a bug in version 5.0.0. Updating to 5.0.1 solved the problem and your query is working now. Thanks for confirmation, it kept me going on the problem 😉

---

<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:** [December 22, 2016, 3:26pm UTC](https://discuss.elastic.co/t/date-math-in-kibana-5/67112/10 "2016-12-22T15:26:22Z")

</div>

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