How do I restrict a survey based on age?

Restricting surveys to participants based on age or date of birth (dob). This concept can also be used to restrict questions within a survey.


Setup:

Create a Text Box field with date validation for the participant’s date of birth.


Create a Text Box field with date validation with the action tag @TODAY, which will allow us to perform our calculations. You may want to add the action tag  @HIDDEN-SURVEY which will hide it from the Participant's view.

 


Create a calculated field to determine the participants age in years, days, etc. If desired, you can also add the @HIDDEN or @HIDDEN_SURVEY action tags

Your calculation will look something like the following. Note in this example, we are using the round function and rounding to 2 decimal places:

round (datediff([today],[dob], "y", "mdy"),2)


Similarly, we can perform the calculation in months as well:

datediff([today],[dob],"M","mdy")


For our example, we are calculating the number of days to determine the age of the participant.

datediff([today],[dob], "d","mdy")

 


Finally, we are ready to add logic to our survey queue. In our example, we are restricting several surveys based on age by number of days. You may find you need to tweak the numbers a bit, as REDCap uses an average of 30.44 days in a month to perform calculations. Of course, it might be easier to create your restrictions based on years, but for the purpose of our demonstration, we are using days. Note: if your project is longitudinal, you’ll need to specify the event name along with the field name in your calculations.

These are the calculations we are using for our scenario:

1 week - 1 year: [age_in_days]<=365

2 Years, 0 months: ([age_in_days]>365) and [age_in_days]<=759

2 Years 1 Month – 2 years 11 months: ([age_in_days]>759) and [age_in_days]<=1094

3 years – 6 years: ([age_in_days]>1094) and [age_in_days]<=2554

7 Years: ([age_in_days]>2554) and [age_in_days]<=2919

8 Years: ([age_in_days]>2919) and [age_in_days]<=3284

9 Years to 10 years: ([age_in_days]>3284) and [age_in_days]<=4014

 




For additional assistance, please contact cru@ucalgary.caÂ