# Query between a range H

**URL:** <https://discuss.elastic.co/t/query-between-a-range-h/196062>\
**Category:** Kibana\
**Created:** [August 21, 2019, 8:27am UTC](https://discuss.elastic.co/t/query-between-a-range-h/196062 "2019-08-21T08:27:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Digital](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/digital/32/41054_2.png) [@Digital](https://discuss.elastic.co/u/Digital)\
**Post date:** [August 21, 2019, 8:27am UTC](https://discuss.elastic.co/t/query-between-a-range-h/196062/1 "2019-08-21T08:27:16Z")

</div>

Hello all 🙂

I'm blocked on one of my queries. I would like to receive the data everyday between  
00H00 to 06H00  
06H00 to 12H00  
12H00 to 18H00  
18H00 to 24H00

But I can't use now-12H or now-6H because I can't to be precise with that.  
MAybe use the time epoch?

Do you have any idea?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [August 21, 2019, 5:24pm UTC](https://discuss.elastic.co/t/query-between-a-range-h/196062/2 "2019-08-21T17:24:14Z")

</div>

Do you have an epoch field in your documents? Or just the time of days? Seeing an example of what a document looks like would help.

> I would like to receive the data everyday between

There are probably a few ways to do it, but the most straightforward that I think you'd have luck with would be to use a Date Histogram aggregation. Given a set of documents with an absolute date (year, month, day, time of day), Elasticsearch can break down stats on a basis of 6-hour periods. You will need to have a field mapped as `date` in the data, which requires some setup.

- Date histogram aggregation: [Date histogram aggregation | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html)
- Date datatype: [Date field type | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html)

Kibana has visualization tools to help you create your own charts and tables of your date using Elasticsearch's Date histogram aggregation. You'll need your data to be set up per the documentation I linked to.

---

<div class="post-metadata">

**Author:** ![Digital](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/digital/32/41054_2.png) [@Digital](https://discuss.elastic.co/u/Digital)\
**Post date:** [August 27, 2019, 11:03am UTC](https://discuss.elastic.co/t/query-between-a-range-h/196062/3 "2019-08-27T11:03:40Z")

</div>

Hello 🙂

I had only the time stamp so I had work with the time epoch and it works correctly now 🙂  
So I suggest to use the time epoch for your query 😉

Best regards

---

<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:** [September 24, 2019, 11:12am UTC](https://discuss.elastic.co/t/query-between-a-range-h/196062/4 "2019-09-24T11:12:35Z")

</div>

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