Solved
How to set dates using piped text around a fixed date with ${e://Field/Date}
Hello Qulatrics community,
I am looking to use dates in basic calculaitons for display logic and validation. I have entered a static date (e.g., "Date" = 12/10/2018) into embedded data and attempted the code below, but the piped text shows up blank. I was told by qualtrics support to try the community to see if there is a way to modify a static date (not a moveable date like ${date://OtherDate/SL/-2%20day}) so that I can set a single date and then use code/syntax to update a series of other entries such as those below.
Response options:
Journal Entry 1 for ${e://Field/Date}
Journal Entry 2 for ${e://Field/Date+1}
Journal Entry 3 for ${e://Field/Date+2}
Journal Entry 4 for ${e://Field/Date+3}
etc.
I know that we can simply enter manually in every date, but with multiple data collections having a single or set of dates that I can enter where all other entries will be updated around them would be very helpful.
Thanks for any help you can provide!
Best answer by fleb
Hi @BFarmer,
I think you'll have to use javascript for that.
1) Convert your date from string to date datatype (more details here)
` var st = "${e://Field/Date}";`
` var dt = new Date(st);`
2) Create all new dates you need in the format you want to have in the text. More details here and here. I recommend writing a function for that.
` var dt2 = new Date();`
` dt2.setDate(dt.getDate()+1);`
` myString = dt2.getDate() + "/" + dt2.getMonth() + "/" + dt2.getFullYear();`
3) Use your new variables as you need. You can put them into embedded data fields using and then use the piped text to access them in following blocks. Or you can create HTML element containing these dates and append it to some question or put them to some question container (e.g.: `jQuery(this.getQuestionTextContainer()).append("Some text "+ myString + "Some other text")`.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
