I am using DateAdd to determine the dates for worker's review periods from a start date.
This has worked fine all year, but now I have a group that span December to January and the date in January has the correct day, but the year is still 2016.
There are 5 consecutive review periods, this is the code for the first two months, the rest just iterates.
The code looks like this:
IntervalType = "y"
StartPeriod = InputBox
EndNumber = 29 ' last day of review period
StartNumber = 30 ' first day of next period
Edate = DateAdd(IntervalType, EndNumber, StartPeriod) ' string
Sdate = DateAdd(IntervalType, StartNumber, StartPeriod)
Edated = Edate ' string as date
SDated2 = Sdate
' Determine 2nd month dates and Sheet names
IntervalType = "y" ' "d" specifies days as interval
StartPeriod2 = SDated2 '
EndNumber2 = 29
StartNumber2 = 30
Edate2 = DateAdd(IntervalType, EndNumber2, StartPeriod2)
Sdate3 = DateAdd(IntervalType, StartNumber2, StartPeriod2)
Is there a way to have DateAdd recognize that the year has rolled over?
Bookmarks