# How to get a document based on creation data with interval of time

**URL:** <https://discuss.elastic.co/t/how-to-get-a-document-based-on-creation-data-with-interval-of-time/74316>\
**Category:** Elasticsearch\
**Created:** [February 8, 2017, 4:32am UTC](https://discuss.elastic.co/t/how-to-get-a-document-based-on-creation-data-with-interval-of-time/74316 "2017-02-08T04:32:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajesh\_elasticsearch](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rajesh\_elasticsearch](https://discuss.elastic.co/u/rajesh_elasticsearch)\
**Post date:** [February 8, 2017, 4:32am UTC](https://discuss.elastic.co/t/how-to-get-a-document-based-on-creation-data-with-interval-of-time/74316/1 "2017-02-08T04:32:47Z")

</div>

Hi Team,

I have a use case like, I have to get the document for every 6 hours  
I do like creationDate \>= current\_timestamp - interval '6 hour' in DB  
But how do I get this in elastic search ?  
My mapping  
"creationDate": {  
"type": "date",  
"format": "yyyy-MM-dd HH:mm:ss",  
"doc\_values": true  
},  
I am using elasticsearch 1.3.7  
Kindly anybody help me on this..  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![wenpos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wenpos/32/15326_2.png) [@wenpos](https://discuss.elastic.co/u/wenpos)\
**Post date:** [February 8, 2017, 4:48am UTC](https://discuss.elastic.co/t/how-to-get-a-document-based-on-creation-data-with-interval-of-time/74316/2 "2017-02-08T04:48:20Z")

</div>

will it applied with time task to get docs per 6 hours?  
this may help [https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-range-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-range-query.html)

---

<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:** [March 8, 2017, 4:48am UTC](https://discuss.elastic.co/t/how-to-get-a-document-based-on-creation-data-with-interval-of-time/74316/3 "2017-03-08T04:48:23Z")

</div>

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