vpetkovic
11/22/2019 - 4:23 PM

Dates in Range

public static List<DateTime> GetDates(DateTime runDate)
{
    return Enumerable.Range(1, DateTime.DaysInMonth(runDate.Year, runDate.Month))
                     .Select(day => new DateTime(runDate.Year, runDate.Month, day))
                     .Where(dt => dt.DayOfWeek != DayOfWeek.Sunday &&
                                  dt.DayOfWeek != DayOfWeek.Saturday &&
                                  dt <= runDate)
                     .ToList();