Bug in DATEDIF in Excel 2007?

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Please see the small table below produced using XL 2007

22 12 25.xlsm
ABC
16/02/20083/03/2008
2
326260 Years 0 Months 28 Days
Sheet2 (2)
Cell Formulas
RangeFormula
A3A3=B1-A1
B3B3=DATEDIF(A1,B1,"d")


Formula in C3:
Excel Formula:
=DATEDIF(A1,B1,"y") & " Years " & DATEDIF(A1,B1,"ym") & " Months " & DATEDIF(A1,B1,"md") & " Days"

In Excel 2000 (at least) all three formulas yield the correct result of 26 days.

Is this a known bug with DATEDIF in XL 2007?

More to the point, is there an alternative formula that will give the equivalent (but correct!) output to the one in C3 in the example?
 
Last edited by a moderator:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hello VoG II

Excel 2003 gives the result of 26 days.

You could try the Morefunc add-in. I have not used this add-in with Excel 2007 and I do not have Excel 2007 on my notebook.

=DATE.DIFF(A1,B1,3)

Dave
 
Upvote 0
Thanks Dave - I may try that but I was hoping for a solution using native Excel functions.
 
Upvote 0
Hello VoG II

I'd be reluctant to suggest an alternative to DATEDIF(A1,B1,"md") which exactly replicates DATEDIF because that sometimes gives odd results, even in versions of Excel before 2007, e.g. if A1 is 31st Jan 2008 and B1 is 1st March 2008 it gives a result of -1

This formula should replicate the results, except for negative ones like that....

=MOD(DAY(B1)-DAY(A1),IF(DAY(B1)< DAY(A1),DAY(B1-DAY(B1)),31))

Not sure if DATEDIF(A1,B1,"y") and others work correctly in Excel 2007......
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,802
Members
449,095
Latest member
m_smith_solihull

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