Print? /// <Summary>
/// Obtain the workday in the date segment [except Saturday and Sunday]
/// </Summary>
/// <Param name = "startDate"> </param>
/// <Param name = "endDate"> </param>
/// <Returns> </returns>
Public static long dateDiff (String startDate, String endDate)
{
DateTime fromTime = CommonFunc. StringToDate (startDate );
DateTime toTime = CommonFunc. StringToDate (endDate );
TimeSpan ts = toTime. Subtract (fromTime); // TimeSpan obtains the time interval between fromTime and toTime.
Long countday = ts. Days; // obtain the total number of Days in the two-day period
Long weekday = 0; // workday
// The cycle is used to deduct the weekends in the total number of days
For (int I = 0; I <countday; I ++)
{
DateTime tempdt = fromTime. Date. AddDays (I + 1 );
If (tempdt. DayOfWeek! = System. DayOfWeek. Saturday & tempdt. DayOfWeek! = System. DayOfWeek. Sunday)
{
Weekday ++;
}
}
Return weekday;