Conditional logic with dates

24 views
Skip to first unread message

Ray

unread,
Aug 1, 2023, 2:08:13 PM8/1/23
to Lifespan Redcap Users
Is it possible to use conditional logic with date fields for example if a date is between 2 dates?

Something like so:

If ([datefield1]BETWEEN date 1 AND date 2,"Q1",If ([datefield1]BETWEEN date 3 AND date 4,"Q2",If ([datefield1]BETWEEN date 5 AND date 6,"Q3",If ([datefield1]BETWEEN date 7 AND date 8,"Q4),"Err"))))

I have been trying everything I can think of with no joy.

Thanks in advance.

Kent Armeson

unread,
Sep 12, 2023, 4:13:22 PM9/12/23
to Lifespan Redcap Users
There is no BETWEEN function. You'd need to break it down into more statements with the datediff function, e.g., in the first portion of your IF statement:
IF(datediff([date 1], [datefield1], 'd') > 0 AND  datediff([datefield1], [date 2], 'd') > 0, "Q1", IF(...

Reply all
Reply to author
Forward
0 new messages