Using Date of birth to restrict further capturing

Leap years and such make it challenging to calculate age. Can you ask the respondent's age and then use that answer to control the rest of the survey?

I've modified your survey to use the int((${doi} - ${respondent_dob}) div 365) to calculate the age. And you can see that it doesn't work sometimes if the month/day of the two dates are close.
age_check.xlsx (14.2 KB)

Correct:

Wrong:

Correct:

I played around and I think the following works? If there's a less complex way to do it, I'd be interested to know. The narrative logic below is what I tried to implement in age_from_dates.xlsx (9.0 KB).

if birth month < than current month  
  then age is current year - birth year
  else if birth month  > current month
      then age is current year - birth year - 1
      else if  birth day > current date (we now assume birth month = current month)
        then age is current year - birth year - 1
        else age is current year - birth year