# Date range filter

**URL:** <https://discuss.elastic.co/t/date-range-filter/13115>\
**Category:** Elasticsearch\
**Created:** [August 8, 2013, 12:03am UTC](https://discuss.elastic.co/t/date-range-filter/13115 "2013-08-08T00:03:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juan/32/1927_2.png) [@Juan](https://discuss.elastic.co/u/Juan)\
**Post date:** [August 8, 2013, 12:03am UTC](https://discuss.elastic.co/t/date-range-filter/13115/1 "2013-08-08T00:03:15Z")

</div>

Hi everyone,

I am new to Elasticsearch, and the scenario that I am facing is that I am  
trying to build a dynamic filter (using C# NEST client). The user will use  
a slider to select an integer for example between 1 and 20 to denote the  
number of years experience someone might have. I need to use this number  
say 'n' to figure out which people should be in the result set. Everything  
is working fine, this is just the last piece of the puzzle.

I have the following mapping (array of workhistory objects =\>  
WorkHistories);

"WorkHistories" :  
{  
"properties" :  
{  
"Employer" :  
{  
"type" : "string"  
},  
"EndDate" :  
{  
"type" : "date",  
"format" : "dateOptionalTime" },  
"JobTitle" :  
{  
"type" : "string"  
},  
"StartDate" :  
{  
"type" : "date",  
"format" : "dateOptionalTime"  
}  
}  
}

Here is the pseudo code for what I am trying to achieve. I had a look at  
MVEL, but I am not sure if this is the correct option to pursue? How can  
this be achieved using filters, ignoring the fact that this is done using  
NEST.

totalExperience = 0;  
foreach experience in workhistories  
begin  
totalExperience += datediff(experience.endDate - experience.startDate)  
end

return totalExperience \>= 'n'

Any help or guidance will be greatly appreciated.  
Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:22am UTC](https://discuss.elastic.co/t/date-range-filter/13115/2 "2017-07-06T02:22:16Z")

</div>

Closed on July 6, 2017, 2:22am UTC


