# Thread: Counting months with DATEDIF

1. I have the following formula in a cell: =DATEDIF(CURRENTMONTH,AK2,"m") where CURRENT is "5/31/09" When AK2 equals 6/30/09, I get zero. When AK2 = 7/31/09, I get 2. What happened to month 1 and how do I avoid this error? I must have the first answer 1, not zero. This issue can throw some big totals off. TYIA!

2. DATEDIF counts the number of whole months that have passed from the start date to the end date.
If the start date is May 13, a whole month will have passed 31 days later (because May has 31 days) on June 13, not yet on June 12.
Similarly, if the start date is May 31, a whole month will have passed 31 days later, on July 1, not yet on June 30.

If you don't like this, you'll have to specify precisely how you would want to define the date difference in all possible circumstances.

3. [quote name='Torquemada' post='778207' date='03-Jun-2009 11:40']I have the following formula in a cell: =DATEDIF(CURRENTMONTH,AK2,"m") where CURRENT is "5/31/09" When AK2 equals 6/30/09, I get zero. When AK2 = 7/31/09, I get 2. What happened to month 1 and how do I avoid this error? I must have the first answer 1, not zero.[/quote]
You might want to look at =ROUND(YEARFRAC((CURRENTMONTH,AK2,1)*12,0) (with which I recently struggled in another thread ).

Edited: my bad, forgot to include "*12"

4. [quote name='Torquemada' post='778207' date='03-Jun-2009 11:40']I have the following formula in a cell: =DATEDIF(CURRENTMONTH,AK2,"m") where CURRENT is "5/31/09" When AK2 equals 6/30/09, I get zero. When AK2 = 7/31/09, I get 2. What happened to month 1 and how do I avoid this error? I must have the first answer 1, not zero. This issue can throw some big totals off. TYIA![/quote]