I am having 2 embedded fields called Hire Date and Termination date and I wanted to calculate tenure through piped text. How to insert a piped text for this. Hire date and Termination date are in date formats where as the tenure should be in a number format like for example 10 years they are in the service.
Solved
How to do math operation in piped text for difference between two dates?
Best answer by Mishraji
You should be using JS for doing this. Following JS should work if difference in days is needed:
var hireDate = new Date("${q://QID1/ChoiceTextEntryValue/1}").getTime();
var terminationDate = new Date("${q://QID2/ChoiceTextEntryValue/1}").getTime();
var diff = parseInt(terminationDate - hireDate);
var days = diff/1000/60/60/24;
Qualtrics.SurveyEngine.setEmbeddedData("Tenure", days);
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
