set birth date as year only

492 views
Skip to first unread message

elda....@gmail.com

unread,
Oct 27, 2022, 6:19:16 PM10/27/22
to redcap open
Hi everyone,
I have a question: because of privacy reasons I cannot put the birth date as complete(d-m-y and similar) but only as year.
There a way to set up the BD as year only?
I would like to not use an integer field because in that cause I could't use it for calculate field between dates.
Specifically I'd calcualte the age using BD and today date.

As far as I know I can't use both date and integer in the same calculated field, right?

Thank you,
Elda.

Luke Stevens

unread,
Oct 27, 2022, 9:24:47 PM10/27/22
to elda....@gmail.com, redcap open

Hello Elda,

 

For year of birth use either:

  • Integer-validated text field with a suitable range, or
  • Dropdown list with suitable range defined as choices

 

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.

el_ da

unread,
Nov 2, 2022, 6:31:09 AM11/2/22
to Luke Stevens, redcap open
Thank you very much!
Reply all
Reply to author
Forward
0 new messages