Using month and year (but not day) to estimate age eligibility | XM Community
Question

Using month and year (but not day) to estimate age eligibility

  • 22 July 2019
  • 1 reply
  • 43 views

Hello, I have no experience with Javascript which seems to be needed for this question.

I am wondering if it is possible to use just month and year of birth to estimate age eligibility (18-25 year olds). Obviously without the day of birth, it would not be precise, but I am looking to use just month and year of birth in order to exclude less than 18 or greater than 25 year olds.

I'm currently using a Javascript survey question from the global library that asks for month and year of birth.

1 reply

Userlevel 7
Badge +27

Hi there, if you still need, there are a couple of ways to calculate an exact age using JavaScript. There are several posts around the community on how this might be done, like here and here.
However, for a rougher approximation of date differences using Month and Year, this can also be approached without JavaScript by using Math Operations in the Survey Flow to calculate a difference in days. 
Your Survey Flow might be set up like the below, where RespondentMonth and RespondentYear are piped in from the collected date values in the survey.
SurveyFlowAge_MonthYear.png

Leave a Reply