public static void Main() {
Console.WriteLine((new DateTime(2016, 06, 13)).BusinessDaysUntil(DateTime.Now));
public static class DateExt {
public static int BusinessDaysUntil(this DateTime firstDay, DateTime lastDay, params DateTime[] bankHolidays) {
firstDay = firstDay.Date;
if (firstDay > lastDay) throw new ArgumentException("Incorrect last day " + lastDay);
TimeSpan span = lastDay - firstDay;
int businessDays = span.Days + 1;
int fullWeekCount = businessDays / 7;
if (businessDays > fullWeekCount*7) {
int firstDayOfWeek = (int) firstDay.DayOfWeek;
int lastDayOfWeek = (int) lastDay.DayOfWeek;
if (lastDayOfWeek < firstDayOfWeek)
if (firstDayOfWeek <= 6) {
else if (lastDayOfWeek >= 6)
else if (firstDayOfWeek <= 7 && lastDayOfWeek >= 7)
businessDays -= fullWeekCount + fullWeekCount;
foreach (DateTime bankHoliday in bankHolidays) {
DateTime bh = bankHoliday.Date;
if (firstDay <= bh && bh <= lastDay) --businessDays;