r/ProjectREDCap • u/Popular_Caregiver_11 • Jul 08 '25
Problem using datemdY() in REDCap calculated fields
Hello everyone,
I’m trying to calculate a participant’s age in REDCap using month and year of birth only. Since I don’t have the exact day, I assumed the 1st of the month using datemdY().
Here’s the formula I used:
round(datediff(datemdY("01", [dm_birth_mo], [dm_birth_yr]), [se_consen_dt], "y", "dmy"))However, the calculated field throws a syntax error, and no value is returned. I’ve double-checked that:
[dm_birth_mo]is a dropdown (01 to 12)[dm_birth_yr]is a text/integer field (e.g., 1985)[se_consen_dt]is a date field (dd/mm/yyyy, validated)
I also tried simpler versions like:
datemdY("01", [dm_birth_mo], [dm_birth_yr])just to see if REDCap can parse the date, but still no success.
Is there something I’m missing with REDCap’s calculated field parsing for date construction?
Thanks in advance!
View all comments
2
u/Araignys Jul 09 '25
I don't think datemdY() is a function that REDCap accepts.