Rob McMullen
Rob McMullen

Reputation: 13

Calculating number of days between two dates

I have two columns in ExCEL: Start Date and End Date. I want to calculate the days in my program based on this. If the End date is blank I want to calculate Start date to today. If the End date contains a date I want to calculate from start date to end date. As an odd side note I have a few where both start and end date cells are blank. I want that to return a blank cell. "B" is my start Date column, "C" is my End Date Column What I have tried so far:

=
IF(ISBLANK(B2), " ",
IF(ISBLANK(C2), DATEDIF(B2,TODAY(),"D",
DATEDIF(B2,C2,"D")))

Upvotes: 0

Views: 563

Answers (1)

Scott Craner
Scott Craner

Reputation: 152450

you do not need DateDif for just number of days. Just subtract the two numbers and format the output as general.

=IF(B2<>"",IF(C2<>"",C2-B2,today()-B2),"")

Upvotes: 2

Related Questions