Datedif formula not accurate

gino59

Active Member
Joined
Jul 26, 2010
Messages
496
Hi all...

Got some great help earlier on the DATEDIF formula, but it doesn't appear to be very accurate.

In cell I12 - (formatted as a date) 5/27/1929
In cell I13 - (formatted as a date) 1/3/2004

Cell I14 Result is 74 years, 7 months, 120 days. ????

Result should be 74 years, 7 months, 7 days.

If I change I13 to a date like 1/31/2004 - I get 74 years, 8 months, 4 days which is accurate. Not sure why the day count comes up as 120 days in the first example.

The formula is:

=DATEDIF(I12,I13,"y")&" years, "&DATEDIF(I12,I13,"ym")&" months, "&DATEDIF(I12,I13,"md")&" days"

Thank you!!

Gino
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Wow, Peter - looks like you've been down this road before!! :laugh:

So, I'm using the one I saw you posted -

=YEAR(D7)-YEAR(C7)-(TEXT(D7,"mmdd")< TEXT(C7,"mmdd"))&" years "&MOD(MONTH(D7)-MONTH(C7)-(DAY(D7)< DAY(C7)),12)&" months "&D7-DATE(YEAR(D7),MONTH(D7)-(DAY(D7)< DAY(C7)),DAY(C7))&" days"

Seems to return the correct value in this particular instance. I'm thinking it might be better to replace my DATEDIF formulas entirely with this (right now, I'm using the formula for about 2000 rows!). That many rows and my eyes are glazing over trying to "validate" the results!

Many thanks as always for your generous help!

Cheers!
Gino
 
Upvote 0
The person to thank really is barry houdini - an absolute genius at date/time issues.
 
Upvote 0
Yeah, Barry's solutions have bailed my butt out many times already! Maybe now we know why DATEDIF isn't an "official" formula in Excel, eh?

I think I've got a bit more faith in Barry's/your formula solution. Might be longer but it appears to break every component of the date out one by one and do the simple math on them.

Again, thanks and best wishes!

Gino
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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