DateDif()

Evagrius Ponticus

Well-known Member
Joined
May 24, 2007
Messages
1,467
Hi,

Can anyone help me understand why this formula gives me a result of -1?


a1 = 7/31/2012
b1 = 3/2/2013


datedif(A1,B1,"MD")
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I believe it's because:

1. The "MD" qualifier is only going to tell you how many days there are between the two dates assuming they are in the same month -- LEAVING off the Years and Months part. So if you put 4/1/07 to 5/2/07 it would result in 1.

2. HOWEVER -- In your example, 7/31/2012 to 3/2/2013, while there are technically 7 complete months, there really is no 2/31/2013. My best guess is that it is calculating 3/3/2013 as the 31st day (the end of the 7th full month) and then showing you that there is -1 day "left over". Notice if you change your end date to 3/3/2013 the result becomes 0. Then 3/4/2013 = 1..etc.

It's odd, and complicated, but mostly odd. Perhaps these explanations and examples could help further explain DATEDIF: http://www.cpearson.com/excel/datedif.aspx
 
Upvote 0
Thanks MVP - The DATEDIF function never makes sense to me :( - all I am trying to do find the difference between those two dates for months and days.

Don't know how you are getting 2 Adam - I tried it again and I still get -1??
 
Upvote 0
I'm on Excel 200 and I'm getting the -1 as an outcome.

Datedif doesn't always create the outcome expected and can give a response in negative days

See the Thread titled "Bug in DATEDIF in Excel 2007?
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

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