There may be times when you want to track the time it takes the user to fill out a form, or a section in the form.

This can be done by storing a corresponding start and end date/time value. When these values are set you will know when the user answers the first and last questions in the target form or section.

Once you have the start and end date/time values, you can then use a DATEDIFF() formula function to calculate the time elapsed in your desired unit of measure.

Step by step guide

Let's use hidden fields for this example as we don't want the user to see these stored values. You can also use text or date/time fields if you wanted to display the start and finish date/time values to the user. We'll also assume you have at least two question fields - one at the start with data name of 'myfirstquestion' and one at the end named 'mylastquestion'.

1. Add a hidden field with the data name of 'starttime' to the start of your form design, and a similar 'endtime' hidden field at the end of the form.

2. In these hidden fields, set the dynamic value to be as follows:

starttime field: FORMAT-DATE(NOW(#{{myfirstquestion}}), 'yyyy-MM-dd HH:mm:ss')

endtime field: FORMAT-DATE(NOW(#{{mylastquestion}}), 'yyyy-MM-dd HH:mm:ss')

Lets explain what the above formula is doing:

  • The NOW() function will note the date/time the moment the function is triggered.
  • The #{{dataname}} parameter means that the NOW function will be triggered whenever an answer is set into the named field.
  • The FORMAT_DATE() function is needed because hidden fields store text, not date, values. If you didn't do this, you would likely lose the time portion of the NOW value.
  • The formatting parameter ensures the date/time is captured as text like: '2016-10-21 14:10:55'

3. The final piece to this solution is to add one more field (Hidden, Text or Number) which has a dynamic value formula to calculate the difference between the finish and start date/time values.

4. This field's formula would be :

DATEDIFF((#{{starthidden}}), #{{finishhidden}}, 'SS')

This will give you the difference in seconds between the start and end times. You can then divide this value by 60 as desired to get a minute value. If you want to get the difference in minutes, hours etc, simply change the 'SS' parameter as needed.

Working examples

To see the above NOW() and DATEDIFF() concepts above in action, take a look at the timesheet apps found in our example catalog. You can install these examples into your account and review the form designs to see time calculations in use that are similar to the above.

Did this answer your question?