# Relative date in range filter

**URL:** https://discuss.elastic.co/t/relative-date-in-range-filter/32167
**Category:** Elasticsearch
**Created:** [October 14, 2015, 12:28pm UTC](https://discuss.elastic.co/t/relative-date-in-range-filter/32167 "2015-10-14T12:28:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Shumkov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shumkov/32/5280_2.png) [@Shumkov](https://discuss.elastic.co/u/Shumkov)
#### Post date: [October 14, 2015, 12:28pm UTC](https://discuss.elastic.co/t/relative-date-in-range-filter/32167/1 "2015-10-14T12:28:08Z")

</div>

Hello guy,

Can i take dates from date histogram bucket and use it in query time?

For example, i have docs:  
{ "date1": "2015-10-01", "date2": "2015-10-15", "date3": "2015-10-12" }  
{ "date1": "2015-10-02", "date2": "2015-10-18", "date3": "2015-10-11" }  
{ "date1": "2015-10-03", "date2": "2015-10-18", "date3": "2015-10-04" }  
...

I want to draw table where rows is date histogram by date1 field.

- First col - date1
- Second col - count of date2 field in range "date1 + 1 day"
- Third col - count of date2 field in range "date1 + 2 day"

Right now i have just solution: programmatically calculate rows and do query (or aggregation) for each row.

P.S. i broke my head already :).

---

<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, 11:44pm UTC](https://discuss.elastic.co/t/relative-date-in-range-filter/32167/2 "2017-07-05T23:44:54Z")

</div>


