Validation of date - answer not possible in the future

Dear all,

Currently we are piloting our questionnaires, and I was wondering how to add a validation to a date question: "When did you take medicine X ? ", with the answer option to pick a date from the calendar.
At the start of the questionnaire, we ask for the date of the health consultation, which is today, “current date”.

Can I put a validation that the date of my question on when the participant took their medicine cannot be later than the date of today, so not in the future?

Since the formats of both question is different, I’ve tried different things that I could find on the forum, but I did not manage to find a solution.

Any syntax suggestions are appreciated,

Thank you,

Hi Brenda,

do you have both questions as type DATE questions?

That is,
Q1: Please record the date of the health consultation. Current time tick box selected in the designer.
Q2: When did the participant took their medicine. Regular date question

If so, you simply can write a validation condition at Q2:


To only validate if they actually have recorded the current timestamp:

IsAnswered(q1) ? q2<q1 : true

Obviously, the second syntax is only useful if there is no enabling condition on q2 (IsAnswered(q1))

If you record q1 somewhat differently, please explain (e.g. Text variable with DD:MM:YYYY format?)


Dear Peter,

Thank you for your quick response. It is precisely what your wrote down: both are DATE question types, so the q2 <= q1 works perfectly here. My confusion resulted from the output in Stata, in which the timestamp also notes down the time, by which comparing the two variables directly is not possible. Luckily here it is, so the solution is actually simple. Thank you for helping me out here!

Kind regards,