R
Robert Zeurunkl
I know everyone's first thought is "Aha! Leap Years." But no.
I'll let the results speak for themselves:
? dateadd("ww",52,"1/1/2005") = 12/31/2005
Groovy! Just what I want.
? dateadd("ww",104,"1/1/2005") = 12/30/2006
Lost one day
? dateadd("ww",156,"1/1/2005") = 12/29/2007
Lost two days
? dateadd("ww",208,"1/1/2005") = 12/27/2008
Lost FOUR days!
The results from adding 52 weeks is what I expect. One day short of
the same date a year later. Each of the next three examples are just
multiples of 52 weeks -- two years, three years, four years, etc.
Between 1/1/2005 and 1/1/2008 there are NO LEAP YEARS. The first leap
year comes into play in Feb/08 - past the end of this range.
Can anyone tell me what's going on, and, if you're feeling really bold,
can you tell me how to consistently end up with the same end day when
adding weeks in multiples of full years?
( --- I know I could just add years, but my users are always working in
numbers that are multiples of weeks. And they are not always full year
increments, otherwise this would be easy. 78 weeks, for instance for a
year and a half. But I think that if I fixed the problem with the year
multiples, that will probably fix any weirdness in the partial-year
multiples too ---).
I'll let the results speak for themselves:
? dateadd("ww",52,"1/1/2005") = 12/31/2005
Groovy! Just what I want.
? dateadd("ww",104,"1/1/2005") = 12/30/2006
Lost one day
? dateadd("ww",156,"1/1/2005") = 12/29/2007
Lost two days
? dateadd("ww",208,"1/1/2005") = 12/27/2008
Lost FOUR days!
The results from adding 52 weeks is what I expect. One day short of
the same date a year later. Each of the next three examples are just
multiples of 52 weeks -- two years, three years, four years, etc.
Between 1/1/2005 and 1/1/2008 there are NO LEAP YEARS. The first leap
year comes into play in Feb/08 - past the end of this range.
Can anyone tell me what's going on, and, if you're feeling really bold,
can you tell me how to consistently end up with the same end day when
adding weeks in multiples of full years?
( --- I know I could just add years, but my users are always working in
numbers that are multiples of weeks. And they are not always full year
increments, otherwise this would be easy. 78 weeks, for instance for a
year and a half. But I think that if I fixed the problem with the year
multiples, that will probably fix any weirdness in the partial-year
multiples too ---).