# Date filter is not working in kibana using DSL query

**URL:** https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299
**Category:** Kibana
**Created:** [May 2, 2019, 7:47am UTC](https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299 "2019-05-02T07:47:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![irobot678](https://avatars.discourse-cdn.com/v4/letter/i/54ee81/32.png) [@irobot678](https://discuss.elastic.co/u/irobot678)
#### Post date: [May 2, 2019, 7:47am UTC](https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299/1 "2019-05-02T07:47:39Z")

</div>

HI ,

i am trying to a write DSL query for particular date range and its not working and i dont know why ?

i have Time (kibana uploaded time) , message and date (the log generated date) as shown in the below image .

 ![date_elastic](https://us1.discourse-cdn.com/elastic/original/3X/5/3/539cd0161bec14262a1206d05263329c98c58a9a.png)

now i want to write a DSL query to a particular date range

i tried with the below code its not working

> {  
> "query": {  
> "range": {  
> "date": {  
> "gte": "2019-04-12 17:48:40,579",  
> "lt": "2019-04-12 17:48:48,247"  
> }  
> }  
> }  
> }

and if i write a filter to display logs only to particular date its working as shown in below image, which says the date field is valid

query :

![elasticquery3](https://us1.discourse-cdn.com/elastic/original/3X/6/d/6dd97d10d4e7e58fd780f1b821c9af99f49df963.png)

output :

 ![elastic3](https://us1.discourse-cdn.com/elastic/original/3X/6/9/69ed3caefa2a46c38f1748abadf9f571f8d549cc.png)

so someone please guide me how to write query that works to display logs of particular date range .

---

<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: [May 2, 2019, 5:42pm UTC](https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299/2 "2019-05-02T17:42:29Z")

</div>

What version of Kibana is this for?

Can you tell me more about the `date` field you're wanting to filter by? Is it not the configured Time Filter field for the index pattern? If so, you can just use the timepicker in the top right which is currently configured for "This week"

---

<div class="post-metadata">

### Author: ![irobot678](https://avatars.discourse-cdn.com/v4/letter/i/54ee81/32.png) [@irobot678](https://discuss.elastic.co/u/irobot678)
#### Post date: [May 3, 2019, 6:56am UTC](https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299/3 "2019-05-03T06:56:52Z")

</div>

HI Tyler,

My kibana version is 6.6.2

The date field we are talking about its a date inside log message

we used grok filter which extracts the date from log message as a separate field

logstash.conf  
input {  
file {  
path =\> "/home/\*.log"  
start\_position =\> "beginning"  
}  
}  
filter {  
grok {  
match =\> ["message","%{TIMESTAMP\_ISO8601:date} [%{LOGLEVEL:log-level}] %{DATA:component} %{DATA:class} %{DATA:method} %{DATA:imei} %{DATA:token} %{GREEDYDATA:message}"]  
}  
}  
output {  
elasticsearch { hosts =\> ["localhost:9200"] }  
stdout { codec =\> rubydebug }  
}

sample log :  
2019-04-29 13:05:31:663 [INFO] DTLS-Connection-Handler-64 o.e.l.s.b.d.BootstrapRedisSecurityStoreImpl getByIdentity Params - identity:7ce2471eced27dee9f3761df8123ba15

output :  
{  
"method" =\> "getByIdentity",  
"path" =\> "/home/logs/b.log",  
"class" =\> "o.e.l.s.b.d.BootstrapRedisSecurityStoreImpl",  
"host" =\> "qolsys-desktop",  
"@timestamp" =\> 2019-04-30T11:10:02.512Z,  
"tags" =\> [  
[0] "\_grokparsefailure"  
],

> "date" =\> "2019-04-29 13:05:31:663",

"message" =\> [  
[0] "2019-04-29 13:05:31:663 [INFO] DTLS-Connection-Handler-64 o.e.l.s.b.d.BootstrapRedisSecurityStoreImpl getByIdentity Params - identity:7ce2471eced27dee9f3761df8123ba15",  
[1] "Params - identity:7ce2471eced27dee9f3761df8123ba15"  
],  
"log-level" =\> "INFO",  
"@version" =\> "1",  
"component" =\> "DTLS-Connection-Handler-64"  
}

The output shows date field now i want to write an dsl query to display all the logs for a particular range of date field

the timepicker is used to sort by logs by uploaded time so it wont be useful

in my case log generated time is in date field and log uploaded time by kibana is in @timestamp and all i want to do filter out the date field .

---

<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: [May 3, 2019, 4:41pm UTC](https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299/4 "2019-05-03T16:41:39Z")

</div>

Is there a reason you wouldn't want the time picker to filter by the timestamp of the actual log message and not the time it was ingested into ES? It seems like this would make more sense in which case you just need to instead extract the timestamp as `@timestamp` and not `date`.

---

<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: [May 3, 2019, 4:48pm UTC](https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299/5 "2019-05-03T16:48:30Z")

</div>

If you want to keep your current setup you can use lucene query syntax to search for the date range in the query bar:

`date:[2019-04-12T17:48:40,579Z TO 2019-04-12T17:48:48,247Z]`

---

<div class="post-metadata">

### Author: ![irobot678](https://avatars.discourse-cdn.com/v4/letter/i/54ee81/32.png) [@irobot678](https://discuss.elastic.co/u/irobot678)
#### Post date: [May 4, 2019, 8:09am UTC](https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299/6 "2019-05-04T08:09:35Z")

</div>

HI tyler ,

i tried this  
`date:[2019-04-12T17:48:40,579Z TO 2019-04-12T17:48:48,247Z]`  
but its not working and its showing a following error

Discover: Expected "\*", "", "\n", "\r", "\t", [\ \t\r\n] or end of input but ":" found.

Error: Expected "\*", "\", "\n", "\r", "\t", [\ \t\r\n] or end of input but ":" found.  
KbnError@[http://localhost:5601/bundles/commons.bundle.js:3:10413](http://localhost:5601/bundles/commons.bundle.js:3:10413)  
\_flatten/\<@[http://localhost:5601/bundles/commons.bundle.js:3:1247185](http://localhost:5601/bundles/commons.bundle.js:3:1247185)  
processQueue@[http://localhost:5601/dlls/vendors.bundle.dll.js:434:199687](http://localhost:5601/dlls/vendors.bundle.dll.js:434:199687)  
scheduleProcessQueue/\<@[http://localhost:5601/dlls/vendors.bundle.dll.js:434:200650](http://localhost:5601/dlls/vendors.bundle.dll.js:434:200650)  
$digest@[http://localhost:5601/dlls/vendors.bundle.dll.js:434:210412](http://localhost:5601/dlls/vendors.bundle.dll.js:434:210412)  
$evalAsync/\<@[http://localhost:5601/dlls/vendors.bundle.dll.js:434:212933](http://localhost:5601/dlls/vendors.bundle.dll.js:434:212933)  
completeOutstandingRequest@[http://localhost:5601/dlls/vendors.bundle.dll.js:434:64422](http://localhost:5601/dlls/vendors.bundle.dll.js:434:64422)  
Browser/self.defer/timeoutId\<@[http://localhost:5601/dlls/vendors.bundle.dll.js:434:67267](http://localhost:5601/dlls/vendors.bundle.dll.js:434:67267)

---

<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: [June 1, 2019, 8:09am UTC](https://discuss.elastic.co/t/date-filter-is-not-working-in-kibana-using-dsl-query/179299/7 "2019-06-01T08:09:39Z")

</div>

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