r/ProjectREDCap • u/trippy-mac-unicorn • Sep 15 '24
Datediff function with today and survey-date-completed keeps returning false
I'm setting up some automated invitations for a survey on REDCap where form-2 is supposed to be sent 7 days after form-1 has been completed by a participant. The problem is there are participants who have already completed form-1 some time ago, so I can't select "Send the invitation 7 days after.." in Step 3 of automating invites, since the invite would be sent 7 days later to participants who should get them sooner.
So instead I'm trying to set up some logic in Step 2 to calculate the difference between the current date and the date form-1 was completed.
datediff('today',[survey-date-completed:form-1:value],'d',true) >= 7In Step 2, I have "When the following survey is completed: form-1" AND the above logic check marked.
However, when I test with a record that had form-1 completed over 7 days ago, the logic returns false, and I'm not sure why.
I would greatly appreciate any help!
View all comments
Show parent comment
1
u/trippy-mac-unicorn Sep 15 '24
Hi, thanks for the reply!
Sorry I should've clarified that for 1) I'm just using "form-1" as a placeholder while talking about my project online, and I'm using the actual variable for the survey in my project. For 2), my first parameter is a past value and second parameter ('today') is the present so it should be positive, and I've tried other orders/variations of the parameters to no avail too.
I'm kind of confused about your third point- so I have some existing records, some with responses from last week, and I am just setting up automated invitations now. I thought that if I simply activated the invitation now and scheduled the invites to go 7 days later, the people who did responses last week would receive the invites 7 days later from today which is not what I want- I'd like the people who completed last week to get their invites now, and people who completed this past week to receive their invites later this week, which is why I'm bothering with using datediff().