I am using DateUtils.SetDate + DateTime.TicksPerDay to increment dates by one. This works through all the dates of a year, but it does not increment when the date is 26th October, 2025. See the code that I have broken up in stages to illustrate the problem. This appears to be associated with the last Sunday of October of any year which is associated with DST. How to resolve this?
DateUtils.SetDate on 26th Oct 2025:
Dim t1,t2, t3 As Long
Dim dd_day, dd_mth, dd_year As Int
t1 = DateUtils.SetDate(2025,10,27) 'Set date to 27th October 2025
t2 = DateTime.TicksPerDay
t3 = t1 + t2 'add one day to 27th October
dd_day = DateTime.GetDayOfMonth(t3) 'The date increments by one to 28th October
dd_mth = DateTime.GetMonth(t3)
dd_year = DateTime.GetYear(t3)
t1 = DateUtils.SetDate(2025,10,26) 'Set date to 26th October 2025 (last Sunday of October)
t2 = DateTime.TicksPerDay
t3 = t1 + t2 'add one day to 26th October
dd_day = DateTime.GetDayOfMonth(t3) 'The date remains at 26th October!!
dd_mth = DateTime.GetMonth(t3)
dd_year = DateTime.GetYear(t3)