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.
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);
Hi Mishraji,
Thanks for your code... I'm looking to do something similar but each day update an embedded field if another embeddedfield (eg. departure date) is within 1 day of today. If so, I'd update an embedded field (eg. Days to go) and then use an update ticket task and a ticket workflow scheduled email to send out a list to the relevent team.
Is there a way I could implement this code or something similar? My main problem is how you'd run through all responses and update those required. The new calulate metric task doesn't seem to handle dates and only works on NPS or averages. Also, creating a Formula embedded field in the data & analysis section also doesn't seem to handle dates either.
Any thoughts most welcome
Thanks
Rod Pestell
Hello,
This JS is perfect for US date formats (MMDDYYY). Has someone adapted it for the European date format DDMMYYY ? This would help. Thanks
By the way, Qualtrics added a new task “Data formula” in the workflows which solves this problem without the need of Java script. Very handy indeed. Thanks Qualtrics Product Management for listening to users requests.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.