Allow survey completition ONLY if at least 3 weeks are missing for the date given in an answer | XM Community
Skip to main content

Hello, I am making a request form for the purchase of materials for events where, in order for me to be able to make the purchase, I need at least 3 weeks to go before the event. For this reason, at the beginning of my form, I ask them to enter the date of the event and I need, in some way, to compare the current date with this date to check the condition and show the block with the regular questions if 3 weeks or more are missing, or a block with special instructions for the purchase when less than 3 weeks are missing.
I read in another forum that it can be done using JavaScript but the truth is that I know very little about programming. If you know how to, or if you have any other ideas on how to compare dates on my form, it would be very helpful.
For the event date question I used the following instructions found in anther forum to display a calendar and it worked fine. I don't know if this information is useful. https://www.qualtrics.com/community/discussion/2349/auto-pick-date-on-qualtrics-calendar
Thanks in advance!

It seems to be a relatively simple problem resolved by manipulating date objects using JavaScript.
If you require specific help with your specific situation, you would need to add a minimal, reproducible example.
For generic advice on how to deal with datetime in Javascript - which should be quite helpful in your situation - see this article.
Perhaps an additional thought would be to simply save the result of the JavaScript in an embedded data variable (using

Qualtrics.SurveyEngine.setEmbeddedData("embedded_data", yourValue)
)and use Branch Logic in the Survey flow to decide what to show to the user.


npetrov937 Thank you very much!
I actually did added a branch logic using:
${date://OtherDate/m%2Fd%2FY/+21 day}
and it seems to be working fine.😁


Leave a Reply