DateDiif one month short

R

roccogrand

I need to calculate the number of months in a period. With one exception,
each period in a group is 12 months long. DateDiff calculates 11 months for
a period that starts October 1, 20xx and ends Sept 30, 20xx.

To solve the problem, I have to add 1 to every calculation. Is this just
the way it is?

Thx.
 
K

Ken Snell [MVP]

DateDiff subtracts based on the "month number" when you ask it for the
number of months, so it's looking at 10 (October) and going to 9 (September)
and seeing a difference of 11. So, yes, it's probably easiest for you to add
one.

Or, depending upon the reproducibility / consistency of your data, perhaps
you could just check the "year" difference if you're always going to go from
October to September:

DateDiff("yyyy",#10/1/04#,#9/30/05#) will yield one year. (And so will
DateDiff("yyyy",#10/1/04#,#1/30/05#) because of the same logic noted above
for how DateDiff does 'its thing'.)
 
Top