# Can't query for date or date range

**URL:** <https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378>\
**Category:** Kibana\
**Created:** [June 4, 2018, 7:53am UTC](https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378 "2018-06-04T07:53:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erik\_M](https://avatars.discourse-cdn.com/v4/letter/e/3bc359/32.png) [@Erik\_M](https://discuss.elastic.co/u/Erik_M)\
**Post date:** [June 4, 2018, 7:53am UTC](https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378/1 "2018-06-04T07:53:31Z")

</div>

Hey,  
I have a problem concerning querying the dates in kibana.  
The raw data is in the following format:  
2018-03-16 00:00:00  
The dates are formatted in the mapping as follows:

```auto
"starts": {
            "type": "date",
            "format": "yyyy-MM-dd 00:00:00"
          }

```

Which is accepted by elasticsearch. Similarly within the discover function of kibana all data points are found and the times are represented as  
starts: March 16th 2018, 01:00:00.000 (in the table)  
starts: "2018-03-16 00:00:00" (as json)

However when searching in kibana discover using two different approaches:  
starts:[\* TO 2019-03-15]  
or  
starts:[\* TO 2019-03-15'T'00:00:00]  
Returns no results at all. No matter the range (and can't search for specific dates either).

If I instead click the magnifying glass with the + sign (Filter for value) I get the following parsing error:  
Discover: failed to parse date field [2018-03-16T00:00:00.000Z] with format [yyyy-MM-dd 00:00:00]

What and where is the formatting wrong? The date format seems correct and basic enough but why does no search or filtering work?

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [June 4, 2018, 9:04pm UTC](https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378/2 "2018-06-04T21:04:24Z")

</div>

Hi Erik,

Can you try searching for your timestamp like this: 2018-05-28T01:02:03.456 without the quotes around it.

We do have an existing issue on having better documentation for it.

> <https://github.com/elastic/kibana/issues/19535>

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [June 4, 2018, 9:05pm UTC](https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378/3 "2018-06-04T21:05:17Z")

</div>

This might also be related: [Discover: failed to parse date field](https://discuss.elastic.co/t/discover-failed-to-parse-date-field/100932/2)

---

<div class="post-metadata">

**Author:** ![Erik\_M](https://avatars.discourse-cdn.com/v4/letter/e/3bc359/32.png) [@Erik\_M](https://discuss.elastic.co/u/Erik_M)\
**Post date:** [June 5, 2018, 1:50pm UTC](https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378/4 "2018-06-05T13:50:13Z")

</div>

Tried your suggestion and still only get parsing errors. Also followed tylersmalley's link but didn't help me. Still can't search for dates or ranges of dates within the discover function.

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [June 6, 2018, 8:51pm UTC](https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378/5 "2018-06-06T20:51:19Z")

</div>

For me, in Discover, this works;

`@timestamp:2015-09-22` (shows just that day's data)  
`@timestamp:2015-09-22T23` (shows just that hour's data)

But an unquoted date/time string containing `:` doesn't work. But quoted it does;

`@timestamp:"2015-09-22T23:50:13.253"` returns just the one doc with that timestamp.

`@timestamp:"2015-09-22T23:50"` also works. Returns docs in that hour:minute.

---

<div class="post-metadata">

**Author:** ![Erik\_M](https://avatars.discourse-cdn.com/v4/letter/e/3bc359/32.png) [@Erik\_M](https://discuss.elastic.co/u/Erik_M)\
**Post date:** [June 7, 2018, 7:24am UTC](https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378/6 "2018-06-07T07:24:36Z")

</div>

Your suggestion helped partially, but enough for it to work!  
For some reason the ONLY format that works is your third description, i.e. the FULL time within quotes. Whenever I skip the quotes or only use date, date+hour, date+hour+minute etc. with quotes the return is "no results" or "parsing error"

---

<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:** [July 5, 2018, 7:24am UTC](https://discuss.elastic.co/t/cant-query-for-date-or-date-range/134378/7 "2018-07-05T07:24:37Z")

</div>

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