Date mathematics | XM Community
Skip to main content

I've seen a few posts on this topic, but none directly answered my question.
I want people to sign up for a post-test, but a specified number of days need to elapse (say 10) between pre-test and post-test.
The post-test date options are (for example): March 1, March 2, and March 3.
The date of the person's pre-test will be embedded data from the distribution list.
The question will be:
Which date do you want to sign up for for your post-test?
March 1
March 2
March 3

with the Display logic for each of the 3 dates being something like:

Display If (datevalue(20210301) - embedded pre-date >= 10)

This is pseudocode, so I know this isn't correct syntax.

In brief, I don't want to display an option less than 10 days after the person's pre-test.

I'm trying to find the most elegant way to do this date math.

Any suggestions or pointers to tutorials already explaining this?

Thanks!

You can take a look at this answer and make the following changes in the To Date JS for it work as you describe above:
Line 9: Change

+1
to
-10

Line 15: Change
minDate 
to
maxDate

This is a demo for the earlier implementation to give you an idea of what's going on.


Thanks. I'll take a look.


Leave a Reply