The importance of time
With some data collection activities, collecting start time, stop time, and elapsed time can be critical pieces of information to have to understand the timing of an activity. Whether it’s an inspection where you want to know the “total time on-site”, a travel time study for traffic analysis, or an environmental observation of park wildlife, having an automatic way to determine the total time is something we considered when building dynamic calculation field expressions.
To show you how this can be done, I’ll use the example of a bus route study, designed to collect information about bus network ridership and travel time from stop to stop, at different times of day. A critical component to traffic studies is understanding the detailed environmentals about the specific route — weekdays vs. weekends, morning vs. afternoon peak times, local traffic situations, and more. The example app I’ve built to collect route study information contains several form fields for logging things about the route, as well as specific details about the bus itself. The workflow plays out like this:
- Data collector boards the bus at a specific stop to ride to another predetermined stop
- When boarding and starting a new record, the collector enters the “boarding time” in a time field up top
- Between stops, the rest of the fields can be filled out — bus cleanliness, estimated rider count, quantities boarding at this stop, etc.
- When the desired stop is reached, the collector logs the “alighting time” noting the end of the ride
Our “Total Time” field is a calculation field that makes use of a specific formula expression for calculating the difference between two time fields, called TIMEDIFF. Using this field, our survey can automatically log the total number of minutes between the two stops.
Using TIMEDIFF, I pass in the two time fields from my survey, along with a parameter for the desired output units (minutes or hours). Then when the team is capturing data this field will automatically fill in as they finalize collection of each survey record.
See our function documentation for calculation fields to see other ways you can use expressions in your apps to calculate results based on entry. Also take a look at our previous post with tips on getting the most from calculation fields. Check out the travel time study app in our gallery to give it a test drive.