I got this code from EE a while ago. It was posted by EDDYKT. I need to have it updated to take in to account the new Daylight Savings Time.
Thank you.
Option Explicit
Private Sub Command1_Click()
Debug.Print CalcDayLightBoundary(2003,
4, 1)
Debug.Print CalcDayLightBoundary(2003,
10, 2)
End Sub
Private Function CalcDayLightBoundary(Yr As Integer, Mon As Integer, Hr As Integer) As Date
Dim tt As Date, NumDays As Integer
On Error Resume Next
tt = DateSerial(Yr, Mon, 1) + TimeSerial(Hr, 0, 0)
NumDays = IIf(Weekday(tt) = 1, 0, 7 - Weekday(tt) + 1)
If (Mon = 10) Then
NumDays = NumDays + 28
If (NumDays > 31) Then NumDays = NumDays - 7
End If
CalcDayLightBoundary = DateAdd("D", NumDays, tt)
End Function
Start Free Trial