How can I add number of days to an embedded data field | XM Community
Question

How can I add number of days to an embedded data field

  • 22 July 2020
  • 3 replies
  • 131 views

Badge +2

I need to add number of days to a calendar question in the survey. For e.g. If the date entered is July 22nd, I need to add 2 days to it and display that. I was trying to use this article as a reference but the answer to the calendar question is a ChoiceTextEntryValue, which is not a date format - https://u.osu.edu/advisingwithqualtrics/job-aids/populating-future-dates/
Do I need to use JavaScript to achieve this?
Any help/ideas would be greatly appreciated.


3 replies

Userlevel 7
Badge +6

NeelamS
I couldn't think of a clean way to explain this in a forum post, so I just did a survey that explains everything. I am positive there are cleaner ways to do this if you know better programming, but this was the cleanest way I could think of with the least amount of programming knowledge needed. It does use some JavaScript, but very little. Be careful about changing the coding and embedded data names, otherwise this won't work properly.

I've included programming notes throughout this to help you understand what is going on, but ultimately you will have to reverse engineer the programming to fit your use-case.
Demo_-_Date_difference_calculation (1).qsf
After posting this I realized that you will need to make a small edit to the math calculation for Day.diff. Use this $e{ abs( e://Field/CD - e://Field/COV.dd ) }.

This needs to include the absolute value for the difference in date, otherwise you can get some negative numbers that won't make sense.

Userlevel 7
Badge +6

I misunderstood the question. It looks like the OP wanted to add a static number of days and not do a calculation based on the current date.

Attached is how to do this with 14 days as the static number.
Demo_-_Date_difference_calculation_-_constant_14_days (1).qsf

Userlevel 3
Badge +18

Thank you,Akdashboard !
Your file helped me out tremendously! I was able to branch this to work for two types of conditions. Appreciate your willingness to share.

Leave a Reply