- Home
·
- Math/Dates
·
- Returns the time offset for the current daylight saving. Ths is set to UK time so the dates and off
Returns the time offset for the current daylight saving. Ths is set to UK time so the dates and off
Returns the time offset for the current daylight saving. Ths is set to UK time so the dates and offset are for GMT/BST - they are clearly
API Declarations
Add it to a handy module
Rate Returns the time offset for the current daylight saving. Ths is set to UK time so the dates and off
(1(1 Vote))
Dim qd As Date
Select Case DatePart("m", dt)
Case 4, 5, 6, 7, 8, 9
GMTOffSet = 1 ' april to september = BST
Case 1, 2, 11, 12
GMTOffSet = 0: Exit Function ' November to February = GMT
Case 3
qd = "31/03/" & DatePart("YYYY", dt)
For n = 0 To 6 ' find last sunday in march
If DatePart("w", qd) = vbSunday Then Exit For ' got our last sunday in the month
qd = DateAdd("d", -1, qd)
Next
GMTOffSet = Sgn(1 + Sgn(DateDiff("d", qd, dt)))
Case 10
qd = "31/10/" & DatePart("YYYY", dt)
For n = 0 To 6 ' find last sunday in march
If DatePart("w", qd) = vbSunday Then Exit For ' got our last sunday in the month
qd = DateAdd("d", -1, qd)
Next
If Sgn(1 + Sgn(DateDiff("d", qd, dt))) = 1 Then
GMTOffSet = 0
Else
GMTOffSet = 1
End If
End Select
End Function
Returns the time offset for the current daylight saving. Ths is set to UK time so the dates and off Comments
No comments yet — be the first to post one!
Post a Comment