need a formula

jpross

New Member
Joined
Oct 15, 2002
Messages
36
I have a cell with at Start date, another cell with a stop date and, aformula to calculate the number of days between them - no problem. When there is a date in the start date cell BUT no date (blank) in the stop cell the cell containing the formula returns #NUM!. HOW DO I get the cell t oreturn a zero (0)?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
On 2002-10-16 14:18, jpross wrote:
I have a cell with at Start date, another cell with a stop date and, aformula to calculate the number of days between them - no problem. When there is a date in the start date cell BUT no date (blank) in the stop cell the cell containing the formula returns #NUM!. HOW DO I get the cell t oreturn a zero (0)?

What formula are you using?

consider

=((B3>0)*(B3-A3))
 
Upvote 0
On 2002-10-16 14:30, jpross wrote:
I'm usingthe formula DATEDIF(a1,a2,"D")

=IF(COUNTBLANK(A1:A2),0,DATEDIF(A1,A2,"D"))

You can substitute A2-A1 for DATEDIF(A1,A2,"D") in the above formula.
 
Upvote 0
So, how do I add an if statement to that formula that will cause the answer to be 0 when a2 is blank.
 
Upvote 0
Dave's formula works fine, but I don't understand why yours doesn't. What formula are you using? When I use a simple =A1-B1 (Stop - Start), and I have nothing entered in A1, I get a negative of the number of days from 1/1/1900 to the start date (ex: null minus 6/30/2002 equals -37,437), I do not get an error message.
 
Upvote 0
In answer to how to show zero if no stop date, and assuming A1 is start date, B1 is stop date, and C1 is the number of days between, in C1 use either:

=IF(B1="",0,B1-A1)
or
=IF(B1-A1<0,0,B1-A1)
 
Upvote 0
On 2002-10-16 14:38, jpross wrote:
So, how do I add an if statement to that formula that will cause the answer to be 0 when a2 is blank.

That formula will give you a 0, whenever A1 or A2 or both cells are empty.
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,194
Members
448,554
Latest member
Gleisner2

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