Difference between duration() and end-start

By instinct, one might think that the value resulting from a calculate field with the duration() function is the same as the difference between the fields end and start. However, this is not the case.

The start and end fields correspond to the date and time a form was opened and completed/finalized, respectively. When someone opens a blank form, the (start) time is captured, and when the form is finalized, the (end) time is captured, always based on the device clock.

By default, all form designs created on the server console (whether you choose to work in the online form designer, or in the spreadsheet design template in Excel or Google Sheets) include the start and end fields, as well as a calculate field containing the duration() function.  We recommend including all three fields in your forms, to help you understand the completion timeline of each form submission.

In contrast, the value stored by duration() returns the total time a form was open actively on screen, in seconds. This excludes:

  1. time that SurveyCTO Collect spent minimized in the background while another app was in focus (or while on the home screen), 
  2. time while the screen is timed out, and, 
  3. time spent using the Go To Prompt option (a button with an arrow pointing to a dot, opening a navigation menu for the form, also useful for review) when opening a saved form.

Some examples of time that is included in the difference between end and start, but not included in duration(), are time elapsed:

  • while a partially filled form sits and waits, after saving and exiting the form for later completion,
  • when the device goes to sleep,
  • when you swap to another app; for example, when taking a picture, where the default camera app opens, and, 
  • if you power off the device.

Therefore, as the duration() does not account for the time a survey is paused, or time SurveyCTO Collect is not on screen, it should be equal to or less than the duration implied by the difference between the end time and start time. See an example below.


The differences between the columns "end-start" and "Duration" can be well explained by the reasons detailed. While this data shows differences of around 10 to 30 minutes, it’s not unusual to find larger gaps. Enumerators can easily keep a form saved, not finalized, for a day or more on their device. Hence, the end-start calculation is a good source of information about the average timeline of a submission. On the other hand, duration() tells you the exact time one takes to fill out a form.

As mentioned above, these three fields rely on the device clock, either to capture the time or to assess how much time has passed. In some rare cases, collected data may contain negative values resulting from calculating end-start. This is the result of a change in the device clock between the start and end time of the form, which can be avoided through locking enumerators out of device settings as discussed here.

Do you have thoughts on this support article? We'd love to hear them! Feel free to fill out this feedback form.


Article is closed for comments.