Calculating the difference in minutes between two times

Calculating the difference between two times is a common requirement. In the example, the user would enter the time they started and when they finished. These times could also be entered by tapping on a button element.


The system automatically performs the calculations to place the total in hours, and fractions of hours in the Hours Worked field. Care has to be taken here, as the employee may work over the midnight period.

To calculate the difference in time the ‘subtractTime()’ function can be utilised. The below example is placed within a button field and initially checks that the two time fields (startTime and endTime) both have a value. Depending on how you want to display the total time there are a couple of ways to do this. If you need the total time in hours as a decimal, the code on line 2 will give you that result. If you need the total in minutes, line 3 will achieve this.


Need further help? Contact our Support Team