DateDiif one month short

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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'.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top