Macro and variable

Hi friends,
Below is the code I wrote for a macro.

$DurationCalculation
if (Variable_Name <= 3) {
(DateOfInterview - DateOfArrival)?.TotalDays;
} else {
(DateOfDeparture - DateOfInterview)?.TotalDays;
}

What I want is to placed this macro in a variable (expression field) so that the duration of stay is calculated according to the choice of the survey point but it is not working.

My questions

  1. Is there any mistake in my code, if yes can anyone help correcting?
  2. If not, what is wrong?

Thank you!