Complex variable

Hi to all,

could I write a complex variable that uses "if, “else if” and “else” statements?

I need to round the “age” with this algorithm and insert a certain number of conditions on various questionnaire’s sections:

if (month_birthday < 10)
{
2019 - year_birthday;

}
else if (month_birthday == 10)
{
if (day_birthday == 1)
{
2019 - year_birthday;
}
else
{
2019 - year_birthday -1;
}
}
else
{
2019 - year_birthday -1;
}

Thank you in advance

Max

Try with this in your variable:

  month_birthday < 10 ? 
    2019 - year_birthday 
    : 
        month_birthday == 10 ? 
            day_birthday == 1 ? 
                   2019 - year_birthday 
            :  2019 - year_birthday -1
        :   2019 - year_birthday -1

Thank you. This solution work fine

1 Like