Calculate age based on a future date? | XM Community
Skip to main content

Calculate age based on a future date?

  • October 25, 2022
  • 4 replies
  • 104 views

Forum|alt.badge.img

Hi all,
I have seen discussion for calculating age on the date of respondents taking the survey. I am creating a registration system where survey respondents will enter their DoB, and later in the survey will be presented with the sessions they are eligible to sign up for based on their age at the time of the program. I plan to calculate the age of respondents on 6/15/2023, but am unsure how to code the JavaScript to do so.
I currently have a question type of text response with DD/MM/YYYY format, and tried to use display logic based on these responses but it does not work. I'm hopeful there is a better solution. I will need to create an embedded data point to use for display logic in showing the session selection based on age.
Thank you in advance!

4 replies

Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • 1555 replies
  • October 25, 2022

palsprograms
The following thread should help you:

How do I calculate the duration between two text entry dates and save as an embedded data? — Qualtrics Community

You need to just make some changes to calculate it based on a static date and in number of years.
Hope it helps!


Forum|alt.badge.img
  • Author
  • 2 replies
  • October 25, 2022

This is super helpful, thank you! Would the date I am looking to use as the second date go in the "placeholder" spot?


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • 1555 replies
  • October 25, 2022

palsprograms
Yes the thread mentioned calculates dates on user entered. You will have to modify it to pick a static date in the placeholder of date2. And change the QID to show calendar correctly.
Hope it helps!


SuhasM
Qualtrics Employee
Forum|alt.badge.img+16
  • Qualtrics Employee
  • 114 replies
  • October 27, 2022

Thank you for being thoughtful and providing links to threads within the community Deepak! 👏