userdocs:redcap_usage:base:save_time_on_form
Differences
This shows you the differences between two versions of the page.
| userdocs:redcap_usage:base:save_time_on_form [2026/03/27 15:36] – created babbagej | userdocs:redcap_usage:base:save_time_on_form [2026/03/27 15:53] (current) – babbagej | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Save time on form ====== | ====== Save time on form ====== | ||
| - | You can automatically | + | You can automatically |
| + | If you want to track time on multiple forms, each form must have its **own pair of variables**. | ||
| + | |||
| + | ===== Form Load Timestamp ===== | ||
| + | |||
| + | ==== Variable Name ==== | ||
| + | [form_load_ts] | ||
| + | |||
| + | |||
| + | This variable records the time when the instrument is first loaded. | ||
| + | |||
| + | ==== Required action tags ==== | ||
| - | The first variable [form_load_ts] stores the time of the first load of an instrument. | ||
| - | This variable needs the following action tags: | ||
| < | < | ||
| @NOW-SERVER @READONLY | @NOW-SERVER @READONLY | ||
| </ | </ | ||
| + | ==== What this does ==== | ||
| + | |||
| + | * @NOW-SERVER sets the value to the current server time when the form initially loads. | ||
| + | * @READONLY prevents users from editing the timestamp. | ||
| + | * The value remains unchanged across page reloads or subsequent visits to the same form instance. | ||
| + | |||
| + | ===== Form Save Timestamp ===== | ||
| + | |||
| + | |||
| + | ==== Variable Name ==== | ||
| + | [form_save_ts] | ||
| + | |||
| + | This variable captures the time of the first save for the instrument. The calculation relies on the form’s completion status, which allows you to control// when// the timestamp is set. | ||
| + | This is particularly useful for surveys, where you don’t want to record a save time until all required fields are completed and the form is marked complete. | ||
| + | ==== Calculation ==== | ||
| - | The second variable [form_save_ts] stores the time of first save of an instrument. | ||
| < | < | ||
| - | @CALCDATE(if(([form_1_complete] >= 0 and [form_save_ts] = '' | + | @CALCDATE( |
| - | </ | + | if(([form_1_complete] >= 0 and [form_save_ts] = '' |
| + | ' | ||
| + | [form_save_ts]), | ||
| + | 0,' | ||
| + | </ | ||
| + | |||
| + | ==== What this does ==== | ||
| + | |||
| + | * Checks whether the form has reached a valid completion state ([form_1_complete] >= 0) | ||
| + | * If the form is eligible and [form_save_ts] is blank, it records the current time | ||
| + | * Once set, the value does not update on subsequent saves | ||
| + | * @CALCDATE ensures the value is stored in proper date/time format | ||
| + | |||
| + | ==== Note: ==== | ||
| + | |||
| + | Make sure the calculation references the correct completion field (e.g., [demographics_complete]) for the instrument where this variable is defined. | ||
| + | |||
| + | ===== Result ===== | ||
| + | With both timestamps in place: | ||
| + | |||
| + | * You can calculate time spent on the form by subtracting [form_load_ts] from [form_save_ts] | ||
| + | * The method works for both instruments and surveys | ||
| + | * Users cannot modify the stored timestamps | ||
userdocs/redcap_usage/base/save_time_on_form.1774640207.txt.gz · Last modified: by babbagej
