Sub Timestamp()
Dim TimeDif As Double, _
DaylightStart As Date, _
DaylightEnd As Date, _
ThisYear As Long, _
IsDaylight As Boolean
Const March As Long = 3
Const November As Long = 11
' Generically you can get the nth xday of the month with this formula
' =DATE(B2,A2,1+7*n)-WEEKDAY(DATE(B2,A2,8-xday))
' daylight start = second (n=2) Sunday (xday =1) in March @ 02:00:00
Const Sunday As Long = 1
Const nth As Long = 2
Const xday As Long = 1 'sunday = 1st day of week
Const TwoAM As Double = 2 / 24
ThisYear = Year(Now())
'begins at 2:00 a.m. on the second Sunday of March and
DaylightStart = DateValue(March & "/" & 1 + 7 * nth & "/" & ThisYear) - Weekday(DateValue(March & " / " & 8 - xday & " / " & ThisYear))
DaylightStart = DateValue(DaylightStart) + TwoAM
'ends at 2:00 a.m. on the first Sunday of November
DaylightEnd = DateValue(November & "/" & 1 + 7 * 1 & "/" & ThisYear)
DaylightEnd = DaylightEnd + TwoAM
'is daylight in effect?
IsDaylight = Now >= DaylightStart And Now <= DaylightEnd
TimeDif = IIf(IsDaylight, 9.5, 10.5) / 24
TimeStampValue = TimeValue(Now() - TimeDif)
End Sub
Bookmarks