This is an old revision of the document!
Table of Contents
Save time of field change
You can automatically capture the time of a field update by using a copy of the field on another form and a conditional date calculation. This information is automatically caputured in the audit log of REDCap, but is is not available in normal reports, skip logic, or other locations that a variable can be used.
If you want to track time of change on multiple variables, each must have its own pair of variables, one a copy of the original value and the other the time of change.
This page will use the example of [first_name] and track the changes to that variable. You can adjust variable names to match your use case.
Copy the current value of variable
Variable Name
[first_name_copy]
This variable records a copy of the variable we want to track changes on. It must exist on a different form than [first_name]. This ensures is it not updated until there is a save event on the server side.
Required action tags
@CALCTEXT([first_name])
What this does
- @CALCTEXT sets the value to match the value of [first_name] at the time of the form save
- Once [first_name] is changed, before it is saved, [first_name] and [first_name_copy] will have different values.
Capture change time
Variable Name
[first_name_change_dt]
This variable captures the time of the value change and needs to be of type date. It will update twice, once when the value on the form is modified and again when that modified value is saved on the server. The calculation relies on the the difference between the current value of name and the copy,
Calculation
@CALCDATE(if([first_name] != [first_name_copy], 'now', [first_name_change_dt]), 0, 'd')
What this does
- Checks whether the name and the previous copy match
- If they do not match, there was a change and it records the current time
- If the values are the same, the value does not update on subsequent saves
- @CALCDATE ensures the value is stored in proper date/time format
Note
It is suggest that the copy and time of change variables be tagged with @HIDDEN. It is likely that the content is not needed by data entry individuals and may lead to confusion.
Result
With both variables in place:
- You can report or create alerts on times of change
- Users cannot modify the stored timestamps
