I want survey 2 to be sent if survey 1 was completed before 09/03/2023. Does anyone know how that might be achieved?
I am specifying conditions for sending surveys. I tried using a smart variable: [survey-date-completed:survey_1] <= 2023-09-03. It says my syntax is valid, but when I test it on records it comes back false for those that should be true.
The way to compare dates in REDCap is to use the
datediff()function in your logic. Here is the syntax:And the documentation from within REDCap:
So, to use logic to check whether a survey was completed before or on a specific date (namely Sep 3), use:
This will return
Trueif the number of days difference between thesurvey_1completed date and September 3 is greater than or equal to 0. If thesurvey_1completed date was September 4, the datediff calculation would return-1due to thereturnSignedValueparameter being set toTrue, and thus the comparison-1 >= 0returnsFalse.Also note that the
[survey-date-completed:instrument]smart variable can be appended with:valueto ensure that the date returned is in the format "yyyy-mm-dd" which is more appropriate for a datediff function.You might be tempted to use the
:valueparameter in your original, but operators like<=and>=(or indeed any such comparison) are simply not reliable with datestrings. In my testing just now, everything returns False.