Calculate the age using a date variable: EDC/CDMS
There are multiple ways to calculate the age using dates. Here are some examples:
Calculate current age (today's age)
If you only have one date variable (date of birth), you can use the following formula:
var d = new Date(); var datestring = d.getDate() + "-" + (d.getMonth()+1) + "-" + d.getFullYear(); getDateDiff(datestring,'{dob}','y');
In this calculation {dob} is the birth date variable (in the DD-MM-YYYY format). Replace this with your own variable name.
Note:The above formula calculates the current age from only one date field and will always be updated when the step is opened in a record.
Calculate the age on a certain date
If you are using two date variables, e.g. date of birth and date of admission, you can use the following formula:
getDateDiff('{date_admission}','{dob}','y');
In this calculation {date_admission} is the admission date and {dob} is the birth date variable (in the DD-MM-YYYY format). Replace these with your own variables.