Jacob
Jacob

Reputation: 59

Calculating difference between two years in excel with if else condition

I want to calculate difference of second date (year) and first date(year). I cannot write formula in excel.

if(quitDate is not empty)
{
  quitDate - startDate
}
else 
{
  presentDate - startDate
}

I know only these two formulas =YEAR(NOW)-YEAR(A1) and = YEAR(B1)-YEAR(A1)

Upvotes: 1

Views: 381

Answers (1)

pnuts
pnuts

Reputation: 59495

I suggest:

=IF(quitDate<>"",quitDate-startDate,NOW()-startDate)  

where I have used Named Ranges (each one cell) for the two dates. I imagine you would prefer to replace those with suitable A1 references to make copying easier.

Upvotes: 1

Related Questions