DATEDIF Months

Robby19

Board Regular
Joined
Mar 19, 2018
Messages
227
I have the formula for the duration of months between 2 dates. However, I need to add 1 month if the end month days is greater than the beginning month. See below for example;

I tried using EOMONTH, but that doesn't seem to do what I need it to. The following Code goes in the Months Required.
Code:
=IF([@ECC]=[@EAS],DATEDIF([@EAS],EOMONTH(EASCO,0),"M"),DATEDIF([@ECC],EOMONTH(EASCO,0),"M"))
[TABLE="width: 500"]
<TBODY>[TR]
[TD]EASCO=[/TD]
[TD][/TD]
[TD]19-Mar-19[/TD]
[/TR]
[TR]
[TD]ECC[/TD]
[TD]EAS[/TD]
[TD]Months Required[/TD]
[/TR]
[TR]
[TD]2-Feb-19[/TD]
[TD]2-Feb-19[/TD]
[TD]1 (needs to be 2 since the day in Mar (19) is greater than the day in Feb (2).[/TD]
[/TR]
[TR]
[TD]21-Jan-19[/TD]
[TD]5-Feb-19[/TD]
[TD]2 (Correct)[/TD]
[/TR]
</TBODY>[/TABLE]
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I was able to work this out. Changed it to days, and divided by 30. Also added a statement that if the ECC or EAS is greater than or equal to EASCO, then the result is 0.

Please note that this solution will not work for everyone as there are more than or in some cases less than 30 days in a month. But for our purposes, 30 days works exactly as needed.

Code:
=ROUNDUP(IF(OR([@ECC]>=EASCO,[@EAS]>=EASCO),0,IF([@ECC]=[@EAS],DATEDIF([@EAS],EOMONTH(EASCO,0),"d"),DATEDIF([@ECC],EOMONTH(EASCO,0),"d")))/30,0)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top