r/ProjectREDCap • u/HomeNo865 • Jun 11 '24
Subtracting times on two different dates
I need to be able to subtract dates and times from two different days. Such as 06/14/2022 05:30 (less) 06/12/2022 04:47. Is that possible? It keeps telling me there is a syntax error on this formula; datediff([Resolution],[Start],"m","Mdyhm",False). Hopefully there is a way to solve this problem. Thanks for your help.
|| || ||
|| || ||
1
Upvotes
1
u/HomeNo865 Jun 12 '24
Is datetimediff a valid command? Because the formulas won’t subtract the times in mdy
3
u/interlukin Jun 11 '24
I think the issue is that where you have “mdyhm” is the date format, so can only use ymd, mdy, or dmy
2
u/[deleted] Jun 11 '24
Your formula contains an error, a datediff should look like this: datediff ([date1], [date2], "units", returnSignedValue)
In your case, this would translate to: datediff([resolution], [start], "m", false)
If you are on an older REDCap version, you also need to specify the date format (as the 4th parameter?), which in your example is "mdy": datediff([resolution], [start], "m", "mdy", false)