I am getting two values from DatePicker (End,Start). I'd like to filter data and get data between those two values.
But i couldn't get it to work the write way.
To focus on the problem, Let's consider the both value (Start Date and End Date)
// Here I want to
//var myDate = new Date();
var startDate = new Date(2013, 1, 28);
var endDate = new Date(2013, 1, 30);
The data I have is like :
var filter_data = {
"type": "FeatureCollection",
"features": [{
"geometry": {
"type": "Point",
"coordinates": [-73.98115508098644, 40.755304404503995]
},
"type": "Feature",
"id": 0,
"properties": {
"Date": "01/20/2013 08:58:03 PM",
"lat": 40.755304404503995,
"lon": -73.98115508098644,
"Address": "33 WEST 44 STREET"
}
},, {
"geometry": {
"type": "Point",
"coordinates": [-73.968253883967947, 40.765050901514641]
},
"type": "Feature",
"id": 1,
"properties": {
"Date": "01/29/2013 02:53:11 PM",
"lat": 40.765050901514641,
"lon": -73.968253883967947,
"Address": "564 PARK AVENUE"
}
},
]
};
To filter the data, I used two different approaches, but none of these approaches work.
var filteredData_2 = filter_data.where( ( n, i ) => n.properties.Date <startDate && n.properties.endDate ) ;
var filteredData = filter_data.filter(function(a){return a.properties.Date >startDate && a.properties.Date <endDate;});
console.log(filteredData_2)
console.log(filteredData)
Here is the like to JsFiddle: