SOLVED

Datedifference

%3CLINGO-SUB%20id%3D%22lingo-sub-1906940%22%20slang%3D%22en-US%22%3EDatedifference%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1906940%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Excel%20Community%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20having%20trouble%20with%20this%20Datedif-formula.%3C%2FP%3E%3CP%3EI%20want%20Excel%20to%20count%20the%20difference%20in%20months%20between%20two%20dates.%3C%2FP%3E%3CP%3EThis%20does%20work%2C%20but%20not%20in%20every%20case%20like%20I%20want%20it%20to.%3C%2FP%3E%3CP%3EConcretely%2C%20I%20have%20the%20following%20issue%3A%3C%2FP%3E%3CP%3EThe%20difference%20in%20Months%20between%2017%2F09%2F2018%20and%2021%2F09%2F2020.%3C%2FP%3E%3CP%3EObviously%2C%2024%20Months%20lie%20between%20these%20two%20given%20dates.%3C%2FP%3E%3CP%3EAlthough%2C%20the%2025th%20Month%20has%20already%20started%20with%204%20days.%3C%2FP%3E%3CP%3ETherefore%20I%20would%20like%20Excel%20to%20do%20the%20following%3A%3C%2FP%3E%3CP%3EThe%20difference%20between%20two%20dates%2C%20expressed%20in%20Months%2C%20but%20taking%20into%20account%20the%20Month%20that%20has%20already%20started%2C%20but%20hasn't%20been%20fully%20passed.%3C%2FP%3E%3CP%3EIn%20the%20beforementioned%20example%3B%20the%20outcome%20is%2024%20Months%20and%204%20days.%3C%2FP%3E%3CP%3ETherefore%2C%20I%20want%20the%20outcome%20to%20be%3A%2025%20Months%20(instead%20of%2024%2C%20as%20it%20does%20so%20now)%20.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20I%20compute%20this%20in%20a%20formula%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20help!%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1906940%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1907027%22%20slang%3D%22en-US%22%3ERe%3A%20Datedifference%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1907027%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F874704%22%20target%3D%22_blank%22%3E%40Tolormo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EROUNDUP%3F%3C%2FP%3E%3CP%3E%3DROUNDUP(DATEDIF(A1%2CB1%2C%22%22m%22%22)%2C0)%3C%2FP%3E%3CP%3Eor%3C%2FP%3E%3CP%3E%3DDATEDIF(A1%2CB1%2C%22%22m%22%22)%2B1%3C%2FP%3E%3CP%3Edepending%20on%20how%20you%20want%20to%20handle%20%22exactly%2024%20months%22%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

Hello Excel Community,

 

I am having trouble with this Datedif-formula.

I want Excel to count the difference in months between two dates.

This does work, but not in every case like I want it to.

Concretely, I have the following issue:

The difference in Months between 17/09/2018 and 21/09/2020.

Obviously, 24 Months lie between these two given dates.

Although, the 25th Month has already started with 4 days.

Therefore I would like Excel to do the following:

The difference between two dates, expressed in Months, but taking into account the Month that has already started, but hasn't been fully passed.

In the beforementioned example; the outcome is 24 Months and 4 days.

Therefore, I want the outcome to be: 25 Months (instead of 24, as it does so now) .

 

How can I compute this in a formula?

 

Thank you for your help! 

 

3 Replies
Highlighted

@Tolormo 

ROUNDUP?

=ROUNDUP(DATEDIF(A1,B1,""m""),0)

or

=DATEDIF(A1,B1,""m"")+1

depending on how you want to handle "exactly 24 months"

Highlighted
Best Response confirmed by Tolormo (Occasional Visitor)
Solution

@MindreVetande 

Perhaps

=DATEDIF(A1,B1,"M")+1*(DAY(B1)<>DAY(A1))
Highlighted

@Sergei Baklan 

Much better. I honestly don't know what i meant with the ROUNDUP thing.

This should also work (except for day Zero)

=DATEDIF(A1,B1-1,"M")+1