Hello Elda,
For year of birth use either:
To then calculate approx. age at some other date you need to create a date field that approximates the birth date from year using @CALCDATE – and rather than using “today” it is usually best to capture the date into a date field using @TODAY so REDCap does not update the value every time you look at the form.
Along these lines, where I have selected the mid-point of the birth year (01-July) as the point from which to calculate approx. age (but you can see that is easy to change if you wish):
Variable / Field Name |
Form Name |
Field Type |
Field Label |
Choices, Calculations, OR Slider Labels |
Text Validation |
Validation Min |
Validation Max |
Field Annotation |
record_id |
default |
text |
Record ID |
|||||
basedate |
default |
text |
Base date |
date_dmy |
@TODAY |
|||
yob |
default |
text |
Year of birth |
integer |
1900 |
2022 |
||
yobmid |
default |
text |
Middle of year |
date_dmy |
@CALCDATE(if([yob]='','',concat([yob],'-','07','-','01')), 0, "d") |
|||
approxage |
default |
calc |
Approx age at basedate |
rounddown(datediff([yobmid],[basedate],"y",true),0) |
I hope that helps.
Regards,
Luke
Luke Stevens
Research Data Systems Manager
Clinical Epidemiology & Biostatistics Unit (CEBU)
Murdoch Children's Research Institute
The Royal Children's Hospital, 50 Flemington Road
Parkville, Victoria 3052 Australia
T +61 3 9345 6552
E luke.s...@mcri.edu.au
W mcri.edu.au
From: redca...@googlegroups.com <redca...@googlegroups.com>
On Behalf Of elda....@gmail.com
Sent: Friday, 28 October 2022 09:19
To: redcap open <redca...@googlegroups.com>
Subject: [EXTERNAL]set birth date as year only
CAUTION: External Email. Please be cautious with attachments and clicking links
--
You received this message because you are subscribed to the Google Groups "redcap open" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
redcap_open...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/redcap_open/39db5b90-f823-425d-928f-c1f012d0680dn%40googlegroups.com.
This e-mail and any attachments to it (the "Communication") are, unless otherwise stated, confidential, may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of Murdoch Children’s Research Institute (MCRI) ABN 21 006 566 972 or any of its related entities. MCRI does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication.