# Elastic search query using ranges

**URL:** <https://discuss.elastic.co/t/elastic-search-query-using-ranges/96735>\
**Category:** Elasticsearch\
**Created:** [August 11, 2017, 9:07am UTC](https://discuss.elastic.co/t/elastic-search-query-using-ranges/96735 "2017-08-11T09:07:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jyoti\_Shukla](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@Jyoti\_Shukla](https://discuss.elastic.co/u/Jyoti_Shukla)\
**Post date:** [August 11, 2017, 9:07am UTC](https://discuss.elastic.co/t/elastic-search-query-using-ranges/96735/1 "2017-08-11T09:07:38Z")

</div>

I want to find out the number of shifts at 5 A.M in the july month. given the shif-time in date and time format.Example "ShiftTime" : "2017-06-14T06:00:00" and I am also having ShiftDate.

Here what I have tried,

"query": {  
"bool": {  
"filter": {  
"bool": {  
"must": [  
{  
"range": {  
"date": {  
"gte": "2015-06-01",  
"lte": "2015-0-30"  
}  
}  
},  
{  
"script": {  
"script": "doc['ShiftTime'].date.hourOfDay == 6 "

```
      }
    }
  ]
}

```

}  
}

}

---

<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 8, 2017, 9:07am UTC](https://discuss.elastic.co/t/elastic-search-query-using-ranges/96735/2 "2017-09-08T09:07:40Z")

</div>

Closed on September 8, 2017, 9:07am UTC

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