Thursday, 21 July 2011

Calculate Working days in a Month

Dim stDate As Date = New Date(Year(dtDate), Month(dtDate), 1)
Dim enDate As Date = New Date(Year(stDate), Month(stDate), DateTime.DaysInMonth(Year(stDate), Month(stDate)))
While stDate < enDate
    If stDate.DayOfWeek <> DayOfWeek.Saturday AndAlso stDate.DayOfWeek <> DayOfWeek.Sunday Then
        intReturnValue += 1
    End If
    stDate = stDate.AddDays(1)
End While
Return intReturnValue

No comments:

Post a Comment