Skip to content Skip to sidebar Skip to footer

Filtering Data In Json For Any Date Range

I have a json file in the following format: [ { 'date_hour': '2014-04-30T18:30:00Z', 'metric': 6986, 'metric_ly': 4337, 'mv': 'OTHERS', 'time_period': 'Da

Solution 1:

Find a silder widget to your liking (there are dozens out there), and assuming your slider widget provides two date values (startDate and endDate), I would use underscore.js for something like this:

var filteredDates = _.filter(values, function(value){ 
    return (value.date_hour.getTime() > startDate.getTime() &&  
        value.date_hour.getTime() < endDate.getTime())
});

Post a Comment for "Filtering Data In Json For Any Date Range"