How to Stop Excel from Calculating the Days Between Two Dates if Cell is Blank?

SusanJohnst

New Member
Joined
Aug 6, 2020
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
We often calculate the amount of days between two dates for calculating interest (=DAYS(A22,A21) OR =A22-A21), but if there's no date in the cell below (i.e. the end date) it will show as a negative number (see image). I guess we would need the formula to assume if the cell is blank that it's either today's date or just not calculate until a date is entered.

Thanks!!
 

Attachments

  • Example.JPG
    Example.JPG
    28.4 KB · Views: 414

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
If End Date was cell A22, to ignore blanks, use:
Excel Formula:
=IF(A22="","",A22-A21)

To default to today, try:
Excel Formula:
=IF(A22="",TODAY()-A21,A22-A21)
 
Upvote 0
How about
=IF(A22="","",A22-A21)
 
Upvote 0
You are welcome.
Glad we could help!
 
Upvote 0
If End Date was cell A22, to ignore blanks, use:
Excel Formula:
=IF(A22="","",A22-A21)

To default to today, try:
Excel Formula:
=IF(A22="",TODAY()-A21,A22-A21)

@Joe4

i am trying to use your formula posted above to calculate the days between Order date and Today() in Cell K7, but i am getting wrong results , can you please take a look what i am doing wrong.

My Goal:
I want K7 to display the numbers of days passed since the order was placed till today. And if there is no Date in cell J7 it should display 0 or " -" , once i get working forumla i will copy/paste in the entire column.



BOOK_2020 - 2 - Copy.xlsm
BCDEFGHIJKLMN
4Α/ΑPRODUCERRelated InvoiceMaterial QtyRelated PRODUCTDeposit StatusMaterial UsedDatesLOT NUMBER
5NameStatusOrder DateDays Since Order
6A0001May Hong1510A800PendingColorbox#NAME?00001A0001
7A0002Han Cartons151A800DoneCartonsDone2020-08-101900-01-0000001A0002
8A0003YiQiang1510A800PendingBlisterDone2020-07-102020-10-0200001A0003
9A000400000A0004
Materials
Cell Formulas
RangeFormula
L6:L9L6=D6
M6:M9M6=B6
I7:I8I7=IF(J7="","Pending","Done")
K6K6=DATEIF($Q$1-J6)
K7:K8K7=IF(J7="",TODAY()-J7,K7-J7)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I6Expression=IF(J6="","Pending","Done")textNO
I8Expression=IF(J8="","Pending","Done")textNO
I8Expression="IF(J1="""",Pending)"textNO
I7Expression=IF(J7="","Pending","Done")textNO
I7Expression="IF(J1="""",Pending)"textNO
Cells with Data Validation
CellAllowCriteria
B6:H9Any value
J6:N9Any value
 
Upvote 0
How about
Excel Formula:
=IF(J6="",0,TODAY()-J6)
and format the cells as general.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,171
Members
452,615
Latest member
bogeys2birdies

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