I know that the question is asked very often but I can not understand the answers already posted.
At the start of a survey, I get a date of birth in the format DD/MM/YYYY (embedded data) and I want to perform a calculation in the background (survey flow) "Current day - Date of birth". but the date of birth is not in the correct format for this.
how to modify this format? or how to do otherwise via a hidden question?
calculation of an age from an embedded data
Best answer by JR33
I found my answer here : https://www.qualtrics.com/community/discussion/12534/how-create-new-survey-embedded-data-age-from-embedded-birthdate-for-reporting-purposes
to sum up :
Define the embedded data field 'age' at the beginning of the survey flow.
Add moment.js to your survey header : ">https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.21.0/moment.min.js">
Add the following JS to a question:
Qualtrics.SurveyEngine.addOnload(function() {
var bdate = moment("${e://Field/BirthDate}","DD/MM/YYYY");
Qualtrics.SurveyEngine.setEmbeddedData('age',moment().diff(bdate,'years'));
});
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
