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

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!

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!


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


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!


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


Leave a Reply