Return to Snippet

Revision: 59904
at October 9, 2012 01:04 by ed_trench


Initial Code
<System.Runtime.CompilerServices.Extension()>
    Function WeekdayDiff(ByVal dte As DateTime, ByVal interval As Integer) As DateTime

        Dim days As Integer
        Dim counter As Integer

        If interval = 0 Then
            Return dte
            Exit Function
        ElseIf interval > 0 Then
            days = 1
            counter = 1
        Else
            days = -1
            counter = -1
        End If

        Do Until days = interval + counter
            dte = dte.AddDays(counter)
            If (dte.DayOfWeek < DayOfWeek.Saturday AndAlso dte.DayOfWeek > DayOfWeek.Sunday) Then
                days = days + counter
            End If
        Loop

        Return dte

    End Function

Initial URL

                                

Initial Description
VB Extension Method for Weekday difference

Initial Title
VB Extension Method WeekdayDiff

Initial Tags

                                

Initial Language
Visual Basic