Hello everybody,
I have used the link below from the excellent site vbnet to calculate past, current and future daylight savings time. I am interested in only current and future daylight savings time. However when I run the code (for US/Canada daylight savings time) it calculates correctly the first Sunday of November. However it is supposed to calculate the 2nd Sunday of March but instead calculates the first Sunday of March. Anybody have any ideas? Thanks
GetTimeZoneInformation: Past, Current and Future Daylight/Standard Dates
I think the issue is with this section of the code:
Code:With tziDate Select Case .wDay 'week in month Case 1 To 4: 'week 1 to week 4 'Calculate the first day in the month, 'and then calculate the appropriate day 'that the time zone change will occur MonthFirstWeekday = Weekday(DateSerial(tziYear, .wMonth, 1)) - 1 tmp = DateSerial(tziYear, _ .wMonth, _ (.wDayOfWeek - MonthFirstWeekday + _ .wDay * 7) Mod 7 + 1) Case 5: 'last week in month 'Calculate the month's last day, 'then work back to the appropriate 'weekday tmp = DateSerial(tziYear, .wMonth + 1, 0) tmp = DateAdd("d", tmp, _ -(Weekday(tmp) - .wDayOfWeek + 7 - 1) Mod 7) End Select




Reply With Quote