Extracting day of the week and month name as embedded data from answer | XM Community
Skip to main content

I have a question in a survey asking the date of the class. I have the default choice as today ${date://CurrentDate/SL} How can I create an embedded data field for the Day of the Week and Month name from this response?

Hi @SandraH ,

Create 2 EDs in your survey flow named selectedDay and selectedMonth and add this code to your question.

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{

const date = new Date(jQuery("#"+this.questionId+" .InputText").val());
const days = 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const months = "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
Qualtrics.SurveyEngine.setEmbeddedData('selectedDay', daysadate.getDay()]);
Qualtrics.SurveyEngine.setEmbeddedData('selectedMonth', monthstdate.getMonth()]);

});

 


Thank you so much!


@vgayraud i tried using this script but didnt work for me. 


Leave a Reply