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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Dave Patton

Well-known Member
Joined
Feb 15, 2002
Messages
4,976
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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))
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
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.
 

jpross

New Member
Joined
Oct 15, 2002
Messages
36

ADVERTISEMENT

So, how do I add an if statement to that formula that will cause the answer to be 0 when a2 is blank.
 

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053
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.
 

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053

ADVERTISEMENT

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)
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
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.
 

Forum statistics

Threads
1,144,766
Messages
5,726,167
Members
422,659
Latest member
RGP268

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
Top