Using math operations on a calendar-type question | XM Community
Skip to main content
Solved

Using math operations on a calendar-type question

  • March 16, 2019
  • 1 reply
  • 20 views

Ekin
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 !

Best answer by Anonymous

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 ); });

1 reply

  • 0 replies
  • Answer
  • March 17, 2019
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 ); });