Date Function

I have two variables in my questionnaire, first one is DOB (i.e Date Of Birth) and the second one is AGE. Now I want to write a syntax which calculate the age and put it into AGE variable by just taking current date and minus the DOB entered.

My question is how do I do it? is by creating new variable or through Macros? what is the function to capture current date?

Thanks in advance.

Munir Mdee

Dear Munir Mdee,

please see the description of function FullYearsBetween() in the following document:

Best, Sergiy Radyakin

Dear All,
The function pdf “Func_mic_doc.pdf”. is not available. kindly send us

Refer to the Syntax Guide online:
https://support.mysurvey.solutions/syntax-guide/

To add to Sergiy’s response, FullYearsBetween needs two date type questions (variables) as its inputs. If DOB is not a date type question, you can still transform it into one using the new DateTime constructor to build one from, say, questions that capture year, month, and day of birth separately. If any components of DOB may be “don’t know”, then you will want to think about how to handle them (e.g., if day is DK, use 15), or how you compute age differently (e.g. if only year is known, define age as the difference between the year of interview and the year of birth).