Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
bgColor#B3D4FF

Average

...

Panel
bgColor#B3D4FF

DateDiff

The ‘DateDiff’ formula is used to evaluate the difference between two Dates

...

or two Times. Parameters include:

  1. The Date (and Time, if available) or Time from which the other date will be subtracted from.

  2. 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)

  3. 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
No = 2

Baseline

pmpiq23

Radio

I like that nobody can tell when I am using a mobile phone intervention.

Strongly disagree = 1
Disagree = 2
Disagree a little = 3
Neither agree nor disagree = 4
Agree a little = 5
Agree = 6
Strongly agree = 7

Baseline

study_startdate

Date

Please select today’s date…

PT enters date on phone:
04/17/2024

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.

...


datediff('today', [study_startdate],'d')>=3

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

...