What its used for
If your field crews need to record total drive time, on-site time, and such, they can enter start times and end times into their XForms field form, and XForms will automatically calculate elapsed time. It can display elapsed time in seconds, minutes, hours, days, months, or years. And if you set this up in a table grid, you can even add up all the elapsed times and SUM them on the table footer.
How to set this up
This is done in the Form Template Designer using an expression named timeDiff. Steps:
- Open your form template
- Add time fields for start time and end time. Something like start_time and end_time
- Add a calculated field, and in the expression block of the calculated field, enter the timeDiff expression. Something like timeDiff({start_time}, {end_time}, ‘minutes’)
timeDiff expression settings
Definition:
Calculates the difference between start time value and end time value and returns the number based on requested unit
timeDiff({start-time-field}, {end-time-field}, ‘unit’)
- start-time-field: Date or Time field ID that contains start time
- end-time-field: Date or Time field ID that contains end time
- unit: one of the followings surrender by single quote
- seconds
- minutes
- hours
- days
- months
- years
Example:
timeDiff({start_time}, {end_time}, ‘hours’)
What it looks like in the Designer tool
What it looks like on the mobile app
What you can do with this info when aggregated
Since its XForms, it can scale
Want to give XForms a try?
Click/tap the button below.