# Date histogram doc count with interval day is correct, but giving more doc count with hour

**URL:** https://discuss.elastic.co/t/date-histogram-doc-count-with-interval-day-is-correct-but-giving-more-doc-count-with-hour/55688
**Category:** Elasticsearch
**Created:** [July 17, 2016, 9:20am UTC](https://discuss.elastic.co/t/date-histogram-doc-count-with-interval-day-is-correct-but-giving-more-doc-count-with-hour/55688 "2016-07-17T09:20:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Dilip\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_kumar/32/15459_2.png) [@Dilip\_Kumar](https://discuss.elastic.co/u/Dilip_Kumar)
#### Post date: [July 17, 2016, 9:20am UTC](https://discuss.elastic.co/t/date-histogram-doc-count-with-interval-day-is-correct-but-giving-more-doc-count-with-hour/55688/1 "2016-07-17T09:20:48Z")

</div>

`Hi ,  
I am writing query to find hourly count with some filter:  
date histogram doc count with interval day is correct, but giving more doc count with hour

For example my query with interval day:  
`GET \_search  
{  
"size": 0,  
"aggs": {  
"eventtime": {  
"filter": {  
"bool": {  
"must": [  
{  
"term": {  
"RW.RT": "152"  
}  
},  
{  
"term": {  
"[RW.RE](http://RW.RE)": "received"  
}  
}

```
           ]
        }
     },

```

"aggregations": {  
"timeslice": {  
"date\_histogram": {  
"field": "RW.DT",  
"interval": "day",  
"format" : "YYYY-MM-dd HH:MM:ss",  
"min\_doc\_count":1  
}  
}  
}  
}  
}}`Output is :` "hits": {  
"total": 147,  
"max\_score": 0,  
"hits": []  
},  
"aggregations": {  
"eventtime": {  
"doc\_count": 6,  
"timeslice": {  
"buckets": [  
{  
"key\_as\_string": "2016-07-14 00:07:00",  
"key": 1468454400000,  
"doc\_count": 6  
}  
]  
}  
}  
}`This is ok..but when i change interval with hour .. Output is`"hits": {  
"total": 147,  
"max\_score": 0,  
"hits": []  
},  
"aggregations": {  
"eventtime": {  
"doc\_count": 6,  
"timeslice": {  
"buckets": [  
{  
"key\_as\_string": "2016-07-14 07:07:00",  
"key": 1468479600000,  
"doc\_count": 1  
},  
{  
"key\_as\_string": "2016-07-14 08:07:00",  
"key": 1468483200000,  
"doc\_count": 2  
},  
{  
"key\_as\_string": "2016-07-14 09:07:00",  
"key": 1468486800000,  
"doc\_count": 4  
},  
{  
"key\_as\_string": "2016-07-14 12:07:00",  
"key": 1468497600000,  
"doc\_count": 1  
},  
{  
"key\_as\_string": "2016-07-14 13:07:00",  
"key": 1468501200000,  
"doc\_count": 1  
}  
]  
}  
}  
}`  
Here in output doc count is 9, this should be 6  
Please help me

`

---

<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, 2017, 10:34pm UTC](https://discuss.elastic.co/t/date-histogram-doc-count-with-interval-day-is-correct-but-giving-more-doc-count-with-hour/55688/2 "2017-07-05T22:34:59Z")

</div>


