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:
...
For 31st January 2008 to 28th February 2008 you can't take any full years or months so the answer is just 28 days, which is the same result DATEDIF gives. this works exactly the same for 2007, as expected...
I would expect 28 to be the answer. But my Excel 2007 gives me 26 days.

I'm using Excel 2007 (12.0.6325.5000) Dutch
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
greetings.

I tried the formulae you gave and only 1 showed a logical answer: =B1-A1

I'm using MS Excel 2007 as well (Office Enterprise).

solution.

you could either:

* switch the contents of A1 & B1 or

* change the Datedif formula in such a way that the earlier date is entered 1st in the argument followed by the latter date (reference date should be entered chronologically).

Hope this helps.

datedif.jpg
 
Upvote 0
oh, btw, i didn't get 26 as the number of days.

instead i got 91 as the difference between 06/02/2008 & 03/03/2008.
 
Upvote 0
oh, btw, i didn't get 26 as the number of days.

instead i got 91 as the difference between 06/02/2008 & 03/03/2008.
That would probably be because I'm guessing your dates are in mm/dd/yyyy format so 06/02/2008 is 2 June 2008 whereas you might note the 'location' of VoG, who originally posted, is the UK so his dates are in dd/mm/yyyy format, meaning 06/02/2008 is 6 February 2008.



That is also why he wouldn't swap A1 with B1 in his formula since they are already in the correct order:
* switch the contents of A1 & B1 or

* change the Datedif formula in such a way that the earlier date is entered 1st in the argument followed by the latter date (reference date should be entered chronologically).
 
Upvote 0
I used the following formula to get the length of service for my employees. I am using two fields...one with their full time date and one for the current date. It seems to work fine except the "days" that show have 12 decimal places. How do I change this so the days do not have decimals?? I've tried removing or changing the "12" below but that doesn't work...just changes the month total.

=YEAR($A$3)-YEAR(N5)-(TEXT($A$3,"mmdd")< TEXT(N5,"mmdd"))&" years "&MOD(MONTH($A$3)-MONTH(N5)-(DAY($A$3)< DAY(N5)),12)&" months "&$A$3-MIN(DATE(YEAR($A$3),MONTH($A$3)-(DAY($A$3)< DAY(N5))+{1,0},DAY(N5)*{0,1}))&" days"
 
Upvote 0
Yes I was using the =NOW() instead of the =TIME(). I am completely self-taught but I've been doing it a while. These are the simple things I miss by just not having run across it in the past. It did work. Thank you.:)
 
Upvote 0
This version uses DATEDIF but should avoid the DATEDIF bugs discussed in this thread....it also allows A3 to be =NOW() or =TODAY() as required

=DATEDIF(N5,$A$3,"y")&" years "&DATEDIF(N5,$A$3,"ym")&" months "&INT($A$3)-EDATE(N5,DATEDIF(N5,$A$3,"m"))
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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