This function will figure out if the given date lands on a weekend.
Public Shared Function IsWeekend(ByVal dateOfInterest As DateTime) As Boolean Dim d, m, y, w As Integer d = dateOfInterest.Day m = dateOfInterest.Month y = dateOfInterest.Year If m = 1 Or m = 2 Then m += 12 y -= 1 End If w = CInt((d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) Mod 7) If w <> 6 And w <> 7 Then Return False Else Return True End If End Function
Another function to do the weekend check could be this:
Private Const ERR_INVALID_DATE = 20000 Private Const ERR_INVALID_DATE_MSG = "Date Required" Public Function IsWeekend(ByVal DateValue As Object) As Boolean Dim dDateValue As Date If Not IsDate(DateValue) Then Err.Raise(ERR_INVALID_DATE, ERR_INVALID_DATE_MSG) Exit Function End If dDateValue = CDate(DateValue) IsWeekend = (Weekday(dDateValue) Mod 6 = 1) End Function
Remember Me
Powered by: newtelligence dasBlog 1.9.6264.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
E-mail
Theme design by Jelle Druyts