Column formula to calculate # of days that have passed either from date or today

Hi all- looking for help with this formula. I'm trying to create a formula that will show how many days a patient was/has been in a program, even if they're no longer in a program. Basically, if the patient arrived to the program (Actual Arrival Date) but is still in the program, I'd want to calculate the days that have passed since the patient's arrival (TODAY-Arrival Date), but if the patient was discharged from the program, I want to show how many days the patient was in the program (discharge date minus actual arrival date). 

See below for my formula- not sure what I'm getting wrong! Appreciate your advice in advance. 

=IF((ISBLANK([Actual Arrival Date]@row), 0,IF((ISBLANK([Discharge Date]@row)),1,2))(TODAY-[Actual Arrival Date]@row),([Discharge Date]@row-[Actual Arrival Date]@row))))

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!