Return to Snippet

Revision: 2915
at May 7, 2007 07:36 by corydeppen


Initial Code
Function workdayNumber(TheDate As Date) As Byte

    ' Determines the work day number within a month
    
    Dim tempDate As Date
    Dim tempWeekDay As Byte
    
    ' Start with the first day of the month
    tempDate = CDate(Format(TheDate, "m/1/yyyy"))
    
    Do While Month(tempDate) = Month(TheDate)
        tempWeekDay = Weekday(tempDate)
        If (tempWeekDay > 1) And (tempWeekDay < 7) Then
            workdayNumber = workdayNumber + 1
            If tempDate = TheDate Then
                Exit Function
            End If
        End If
        tempDate = tempDate + 1
    Loop

End Function

Initial URL

                                

Initial Description

                                

Initial Title
Determine work day number within month

Initial Tags

                                

Initial Language
Visual Basic