this is the stuff i have so far, it's all C#, can't use the DB
protected void Page_Load(object sender, EventArgs e)
{
DateTime temp = DateTime.Today;
for (int i = 1; i < 31; i++)
{
DateTime output = temp.AddDays(i * 1);
//get # of weekend days to subtract
int startDayOfWeek = (int)temp.DayOfWeek;
int endDayOfWeek = (int)output.DayOfWeek;
int weekDays = Weekdays(output, temp);
Response.Write("weekdays: " + weekDays + ", ");
//int weekends = i > weekDays ? i  weekDays : 0;
//Response.Write("Weekends passed: " + weekends + ", ");
output = temp.AddDays(1 * weekDays);
if (output.DayOfWeek == DayOfWeek.Saturday  output.DayOfWeek == DayOfWeek.Sunday)
output = output.AddDays(2);
if (i < 7 && (enddayofweek > startdayofweek  enddayofweek == 0)) //we've gone over the weekend
output = output.adddays(2);
if (i >= 7)
{
output = output.adddays(2 * (i / 7));
if ((int)output.dayofweek == 0  (int)output.dayofweek == 6)
output = output.adddays(2);
}
//Response.Write("end day of week: " + endDayOfWeek);
Response.Write(", number of days subtracted: " + i);
Response.Write(", output day: " + output.ToShortDateString() + " ");
}
}
int Weekdays(DateTime dtmStart, DateTime dtmEnd)
{
// This function includes the start and end date in the count if they fall on a weekday
int dowStart = ((int)dtmStart.DayOfWeek == 0 ? 7 : (int)dtmStart.DayOfWeek);
int dowEnd = ((int)dtmEnd.DayOfWeek == 0 ? 7 : (int)dtmEnd.DayOfWeek);
TimeSpan tSpan = dtmEnd  dtmStart;
if (dowStart <= dowEnd)
{
return (((tSpan.Days / 7) * 5) + Math.Max((Math.Min((dowEnd + 1), 6)  dowStart), 0));
}
else
{
return (((tSpan.Days / 7) * 5) + Math.Min((dowEnd + 6)  Math.Min(dowStart, 6), 5));
}
}
