Panel | ||
---|---|---|
| ||
Average |
...
Panel | ||
---|---|---|
| ||
DateDiff |
The ‘DateDiff’ formula is used to evaluate the difference between two Dates
...
or two Times. Parameters include:
The Date (and Time, if available) or Time from which the other date will be subtracted from.
The Date (and Time, if available) or Time from which will be subtracted from the first parameter.
For the above two parameters, the date can be optionally specified as the following strings:
'now' → Date and time at the moment logic is evaluated
'today' → Date on which the formula is evaluated
'yesterday' → Yesterday’s date (no time component)
'tomorrow' → Tomorrow’s date (no time component)The format in which the result is required
The format can be:
'd' → total days
'h' → total hours
'm' → total minutes
's' → total seconds
...
DateDiff('yesterday', ‘now', ‘m')
This calculates the total minutes between yesterday’s date (parameter 1) and the date and time for right now (parameter 2).
If yesterday's date is 07/10/2023 and we are evaluating this function at for 07/11/2023 at 4:07p.m. then the results (in minutes) should look like: ‘yesterday’ (Parameter 1) minus ‘now’ (Parameter 2) = -2407.5039294216667
...
When do I use DateDiff to change stages?
DateDiff can be used when you want to change to the next stage after a certain amount of time has elapsed since a after the date question has been answered.
...
Stage Name | Question Name | Question Type | Question Text | Response |
---|---|---|---|---|
StartStudy | nextstage | Radio | Would you like to start the study? | Yes = 1 |
Baseline | pmpiq23 | Radio | I like that nobody can tell when I am using a mobile phone intervention. | Strongly disagree = 1 |
Baseline | study_startdate | Date | Please select today’s date… | PT enters date on phone: |
The Formula Based “StartStudy” stage contains an assessment that includes a radio question type named “nextstage” and when answered with “yes”, it will transition to the “Baseline” stage.
The Formula Based “Baseline” stage contains a baseline assessment that includes a radio question type named “pmpiq23” and when answered (since all responses are greater than 0) will transition to the “FinalStage”. However, if the baseline assessment is not answered within 3 days (as shown in the example below), then the stage transition from “Baseline” to “FinalStage” will still occur.
The “FinalStage” stage is Time Based and will only be active for 1 day (24 hours) since the stage does not end at midnight.
...
| |||
---|---|---|---|
Current Date | Question Variable | Result | Interpretation |
today = 04/17/2024 | study_startdate = 04/17/2024 | 0 | False - stays in the current stage |
today = 04/17/2024 | study_startdate = 04/12/224 | 5 | True - transitions to next stage |
...