This calculation needs certain things to be completed in the form fields in order to work.

Object names of target fields:

  • Start Time = [startTime]
  • Finish Time = [finishTime]


Other things to always remember:

  • The "Advanced Calculation" setting must be selected in the calculation field settings.
  • All Time / Date fields used in the calculation must be set to "Required" in the field settings


Use the below code in the calculation field


var timediff = myNS.helper.time_diff( "01/01/1999 [startTime]", ([startTime] > [finishTime] ? "01/02/1999 [finishTime]" : "01/01/1999 [finishTime]") ); value = (timediff.hours + ((timediff.minutes / 60)));


Once added to the form, this will display as below:



Where the time calculation needs to include deductions for breaks, the following also applies to the form fields. 


Object name of target field (alongside the above listed names)

  • Breaks (if used) = [minusBreaks]


To ensure the break amount is populated in the correct number format for the time calculation, the following structure is required:

  1. Add a multiple choice field with the break options
  2. Add a separate number field which we will use to set the value of the break. Update this field to the [minusBreaks] object name
  3. Depending on the break amounts, add the event from the multiple choice selection, to set the value in the [minusBreaks] field as a decimal amount. E.g.



Use the below code in the calculation field:

var timediff = myNS.helper.time_diff( "01/01/1999 [startTime]", ([startTime] > [finishTime] ? "01/02/1999 [finishTime]" : "01/01/1999 [finishTime]") ); value = (timediff.hours + ((timediff.minutes / 60))) - [minusBreaks];

Once added to the form, this will display as below: