Calculating between two dates

Calculating between two dates

So far i'm able to calculate the days between two dates, but  is there a way where it can update the number of sick days the person has instead of it defaulting to the initial 14. For example I put in for Mike that he was sick between  14 and 15 and now he has 12 sick days left, is there a way where if I put that Mike has another 3 sick days it will use the formula from the previous email but instead of 14 it will use 12? This is the formula i have so far but i keep on getting a error message. i had to create two form so dat it could change the number of sick days.

To get sick days entry in my Main Form:

 

getSdays = myNewForm [email == input.email ];

availableSdays = getSdays.Sick_Days_Left;

if (input.Type  ==  "Sick")

{

    input.Sick_Days_Left = (14 availableSdays -  (input.End_Date - input.Date_Time)  /  (1000  *  60  *  60  *  24)).round(2);

}

 

To add/update sick days entry in the New Form:

 

getSdays = myNewForm [email == input.email ];

getSdays.Sick_Days_Left = input.Sick_Days_Left
 
availableSdays = getSdays.Sick_Days_Left
 
And this is my error message:

Error details:

Error occured while on Success script.

Unable to update variable availableSickdays

getSickdays.Sick_Days_Left is null

getSickdays is null
 
Please help