[ASP.NET] 計算兩時間扣除週末的時間差

Standard
    ''' <summary>
    ''' 兩個時間扣除週末(六日)的時間差有幾天
    ''' </summary>
    ''' <param name="dtst">開始時間</param>
    ''' <param name="dtend">結束時間</param>
    ''' <returns>幾天(Integer)</returns>
    ''' <remarks></remarks>
    Private Function DaysIgnoreWeekends(ByVal dtst As DateTime, ByVal dtend As DateTime) As Integer
        Dim days As TimeSpan = dtend.Subtract(dtst)
        Dim count As Integer = 0

        For a As Integer = 0 To days.Days
            If dtst.DayOfWeek <> DayOfWeek.Saturday AndAlso dtst.DayOfWeek <> DayOfWeek.Sunday Then
                count += 1
            End If
            dtst = dtst.AddDays(1.0)
        Next

        Return count
    End Function

原始出處: (C#版本)
http://www.daniweb.com/forums/thread241280.html

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *