代码如下
public int CountTime(DateTime FromDate, DateTime ToDate)
{TimeSpan ts = FromDate.Subtract(ToDate).Duration();
Days+= Convert.ToInt32(ts.Days.ToString())-1;
int FromWeek = GetWeek(Convert.ToDateTime(FromDateTime).DayOfWeek.ToString());
int ToWeek = GetWeek(Convert.ToDateTime(ToDateTime).DayOfWeek.ToString());
if (ts.Days + FromWeek > 5)
{
Days -= (ts.Days + FromWeek) / 7 * 2;
if ((ts.Days + FromWeek) % 7 == 6)
{
Days -= 1;
}
}return Days;