I have 3 functions, to do the date range filter in a range of 2.
So, I have a start date and an end date, and within those two dates it looks for a table within its three and all dates that will be in that range.
The functions used to make this range (which is gurdated in an array):
// prototype of dates
Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf())
dat.setDate(dat.getDate() + days);
return dat;
}
//GET DATES INTERVAL FUNCTION
function getDates(startDate, stopDate) {
var dateArray = new Array();
var currentDate = startDate;
while (currentDate <= stopDate) {
dateArray.push( new Date (currentDate) )
currentDate = currentDate.addDays(1);
}
return dateArray;
}
And here where the change occurs that triggered these functions and within it I want you to look for that range of dates that I need:
$("#start").keydown(function(event) {
var d1 = new Date($(this).val());
var d2 = new Date($("#end").val());
console.log(getDates(d1,d2));
});
$("#end").keydown(function(event) {
var d1 = new Date($("#start").val());
var d2 = new Date($(this).val());
console.log(getDates(d1,d2));
});