Date Difference, How to return a positive, negative, or 0 number in a formula

nhbartos

Board Regular
Joined
May 23, 2015
Messages
148
Hi folks...
Novice here...

I need help with a formula. I am looking for the difference in days, between dates, that can EITHER return a positive or negative number.

Say I have a "goal" date of 5/30/15, and the goal is obtained before the "goal" date, say 5/28/15. I would like to return a -2 value.
AND, I would like a 0 returned if the goal is met on the goal day of 5/30/15.
AND, I would like a 2 returned, for example if the goal date is exceeded on 6/1/15.

Is there a way to do this in one formula?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to the board.

Assuming your goal date is in A1 and the obtained date is in B1:

=B1-A1

Excel stores dates as whole numbers. Just make sure that the cell that contains the formula is formatted as general, not as date.
 
Upvote 0
That worked. Was I overcomplicating it?

Thanks!

You're welcome. Just remember that dates in Excel are whole numbers starting from 1/1/1900. Using your example dates, 5/30/15 is 42154 and 5/28/15 is 42152. So 42152 - 42154 = -2. Dates are easy but times start to get complicated.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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