Duration formula that returns "0" If there are blank fields

Jalayne

New Member
Joined
Sep 24, 2021
Messages
6
Office Version
  1. 365
I'm trying to create a "duration" Column from a spreadsheet that allows for a returning a "0" if both "start date" and "end date" columns are blank. So far I've got the following which calculates duration and also returns a value using the current date if "End Date" is empty, so i just need to know how to add to this formula to get a "0" if there no date in either column:

=IF(ISBLANK([@[PoP End]]),TODAY()-[@[PoP Start]],[@[PoP End]]-[@[PoP Start]])

Thanks in advance!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi & welcome to MrExcel.
How about
Excel Formula:
=IF([@[PoP Start]]="",0,IF([@[PoP End]]="",TODAY()-[@[PoP Start]],[@[PoP End]]-[@[PoP Start]]))
 
Upvote 0
Hi Jalayne,

I've only Excel 2016 so I had to repove the spaces from the column names, but otherwise this should work:

Jalayne.xlsx
ABC
1PopStartPoPEndResult
21/1/20211/23/202122
30
41/1/20210
50
61/1/20212/2/202132
71/1/20213/3/202161
Sheet1
Cell Formulas
RangeFormula
C2:C7C2=IF(AND(ISBLANK([@PoPEnd]),ISBLANK([@PoPEnd])),0,IF(ISBLANK([@PoPEnd]),TODAY()-[@PopStart],[@PoPEnd]-[@PopStart]))
Named Ranges
NameRefers ToCells
PoPEnd=Sheet1!$B$2:$B$7C2
PopStart=Sheet1!$A$2:$A$7C2
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
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