Working Days This Month
Skip Navigation Links.

Working Days This Month

Skip Navigation LinksHome :: Visual Basic :: Working Days This Month

Here's a simple Visual Basic function you can use in Vb6+/MS Access to calculate the number of working days this month

Public Function BizDay() As Integer
'returns the number of working days this month (to date)
        Dim Msg As String
        Dim D2 As Variant
        Dim Count As Integer
        Dim Sunday As Integer
On Local Error GoTo BizDay_Err

    Sunday = 0
    Count = 1
    D2 = DateSerial(Year(Date), Month(Date), Count)
    Do While D2 < Date
            If WeekDay(D2) = 1 Then
                Sunday = Sunday + 1
            End If
            
            Count = Count + 1
            D2 = DateSerial(Year(Date), Month(Date), Count)
     Loop

   BizDay = Count - Sunday - 1

BizDay_End:
   Exit Function

BizDay_Err:
   Msg = "Error #: " & Format$(Err.Number) & vbCrLf
   Msg = Msg & Err.Description
   MsgBox Msg, vbInformation, "BizDay"
   Resume BizDay_End

End Function

Copy and paste the Visual Basic code below into your module

Please Link to us Next >> Delete Directory
top of page
all content ©1996/2012 BennySutton.com
all images © their respective owners This site uses Thumbshots previews