/// <summary>
/// 计算两个日期之间的工作天数/// </summary>
/// <param name="startdate">起始日期</param>
/// <param name="enddate">中止日期</param>
/// <returns></returns>
public static int DaysInField( string startdate,string enddate
{
DateTime d1 = Convert.ToDateTime(startdate);
DateTime d2 = Convert.ToDateTime(enddate);
int workdays = 0;//返回值
TimeSpan ts = d2.Date-d1.Date;
int days = ts.Days;//自然天数
for( int i=0;i<=days;i++
{
DateTime dtTemp=d1.Date.AddDays(i);
if((dtTemp.DayOfWeek!=System.DayOfWeek.Sunday) && (dtTemp.DayOfWeek!=System.DayOfWeek.Saturday))
{
workdays++;
}
}
return workdays;
}
/// 计算两个日期之间的工作天数/// </summary>
/// <param name="startdate">起始日期</param>
/// <param name="enddate">中止日期</param>
/// <returns></returns>
public static int DaysInField( string startdate,string enddate
![](http://www.blogcn.com/images/wink.gif)
{
DateTime d1 = Convert.ToDateTime(startdate);
DateTime d2 = Convert.ToDateTime(enddate);
int workdays = 0;//返回值
TimeSpan ts = d2.Date-d1.Date;
int days = ts.Days;//自然天数
for( int i=0;i<=days;i++
![](http://www.blogcn.com/images/wink.gif)
{
DateTime dtTemp=d1.Date.AddDays(i);
if((dtTemp.DayOfWeek!=System.DayOfWeek.Sunday) && (dtTemp.DayOfWeek!=System.DayOfWeek.Saturday))
{
workdays++;
}
}
return workdays;
}