Using math operations on a calendar-type question | XM Community
Solved

Using math operations on a calendar-type question

  • 16 March 2019
  • 1 reply
  • 6 views

Hi ! Is it possible to use math operations in a calendar-type question to use it as piped text in a subsequent question ?

What I mean is, if a participant selects April 1, 2019 on a calendar question, what should I do so that they will later see April 3, 2019 on a subsequent question? (Regardless of what date they choose in the first question, I want all respondents to see 2 days after that on a subsequent question). Is this possible?

Thank you very much !
icon

Best answer by Anonymous 17 March 2019, 07:11

View original

1 reply

Hello @Ekin ,

Create an Embedded data (NewDate) in the survey flow before the date question

Paste the below code in the js(onReady) of the date question:

jQuery("#"+this.questionId+" .InputText").bind("input propertychange",function(){

var s = jQuery(this).val();
var date = new Date(s);
var newdate = new Date(date);
newdate.setDate(newdate.getDate() + 2);
var dd = newdate.getDate();
var mm = newdate.getMonth() + 1;
var y = newdate.getFullYear();
var someFormattedDate = mm + '/' + dd + '/' + y;
Qualtrics.SurveyEngine.setEmbeddedData( 'NewDate',someFormattedDate );

});

Leave a Reply