Share via

Month Calculation Error

Anonymous
2023-12-13T06:52:05+00:00

I am calculating no of months using "=IFERROR(MONTH(AJ1315-AI1315),0)" formula. AI is the end date and AJ is the start date. It gives me right answer for all months except for July. Instead of showing 6 from July to December, it is showing 7 months.

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. riny 20,870 Reputation points Volunteer Moderator
    2023-12-13T08:03:16+00:00

    It's important that you understand why that happens here. When you have a start data of July 1 and an end date of Dec 31, then End minus Start will result in the number 183. Then =MONTH(183) will indeed returns 7, because it will return the month number of the 183rd day in Excel's internal calendar, being July 1, 1900.

    If you always want to calculate the number of months within the same calendar year, and from the first day of one month to the last day of another, Vijay's formula will work. but it doesn't when you cross the calendar year end. Try and you will see.

    In Excel you can use the DATEDIF function ( https://support.microsoft.com/en-us/office/datedif-function-25dba1a4-2812-480b-84dd-8b32a451b35c ). But this a tricky one as it may produce incorrect answers as it works with whole months and whole years. You'll have to understand what it's doing and how to work with it.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-12-13T07:59:55+00:00

    Could you share us some data and expected result?

    Try this one.

    =IFERROR(DATEDIF(AI1315, AJ1315, "m"),0)+1

    DATEDIF function - Microsoft Support

    Image

    Was this answer helpful?

    0 comments No comments
  3. Vijay A. Verma 104.8K Reputation points Volunteer Moderator
    2023-12-13T07:16:44+00:00

    Use following formula

    =IFERROR(MONTH(AJ1315)-MONTH(AI1315)+1,0)

    Was this answer helpful?

    0 comments No comments