Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Is there a way to capture an age variable?

  • torilee93
  • torilee93's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 7 months ago #205817 by torilee93
Hello,

I am wondering if limesurvey can capture age variables to perform calculations later in the survey

For example, the 1st question will be What is your dog's date of birth?

Then depending on the answer, the questions below will show.

If the dog's age is 1 years old or below, ask has your dog had any vaccinations ?

If the dog's age is between 1 and 12 years old, ask has your dog been potty trained?

If age is over 12 years old, has your dog been sprayed?


Thank you for your time and help!

- Tori
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #205824 by Joffm
Replied by Joffm on topic Is there a way to capture an age variable?
Hi, Tori,

Something like this will give the difference in days between the current date and a value entered in a Date type question with question code "birthday":
Code:
{floor((strtotime('now')-strtotime(birthday))/(60*60*24))}

So create a question of type equation (QDays) with this code
And your next question will look like this:

{if(QDays<366,"has your dog had any vaccinations ?",if(QDays<4380,"has your dog been potty trained?","has your dog been sprayed?"))}

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: torilee93
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose