Filter based on if a date range falls on a specific day of the week

Click here for a video tutorial on how to set this up.

Here’s the code for the Pipe Request

var start_date = "{startDate}";
var end_date = "{endDate}";
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
function getDates(dateStart, dateEnd) {
  var currentDate = dateStart,
      dates = [];
  while(currentDate <= dateEnd) {

    // append date to array
    dates.push(currentDate);

    // add one day
    // automatically rolling over to next month
    var d = new Date(currentDate.valueOf());
    d.setDate(d.getDate() + 1);
    currentDate = d;

  }
  return dates;
}
function filterWeekDays(dates, includeDays) {
  var weekdays = [];

  // cycle dates
  dates.forEach(function(day){

    // cycle days to be included (so==0, mo==1, etc.)
    includeDays.forEach(function(include) {
      if(day.getDay() == include) {
        weekdays.push(weekday[day.getDay()]);
      }
    });
  });
  return weekdays.toString();
}
var dates = getDates(new Date(start_date), new Date(end_date));
filterWeekDays(dates, [0,1,2,3,4,5,6]);