Calculating the difference between two date/time fields
To calculate the difference between two date/time fields, create hidden fields that convert the time/date values gathered by time/date fields into a specific format using FORMAT-DATE. Then create another hidden or visible field with a dynamic value that uses the DATEDIFF function to calculate the difference between the two hidden fields.
In the below example, {{timeDiff}} is formatted with 'HH' to show hours. This can be modified to show the time difference in another format, such as hours and minutes, etc. Please see this article for more detail on data/time format codes.
startTimeHidden:
FORMAT-DATE({{startTime}}, 'yyyy-MM-dd HH:mm:ss')
endTimeHidden:
FORMAT-DATE({{endTime}}, 'yyyy-MM-dd HH:mm:ss')
timeDiff:
DATEDIFF({{StartTimehidden}}, {{EndTimeHidden}}, 'HH')

Related Articles
Calculating the Duration/Time elapsed between two form fields
For some questionaire/survey-type scenarios, you may wish to track the time it takes the user to fill out a Form, or maybe a section in the Form. This is done by storing a corresponding start and end date/time value, with these values being set when ...
Date/Time Field Type
TABLE OF CONTENTS Basic Properties Data Name Title Text Hint Text Date/Time Type Working with Date & Time values in formula and bound Data Source scenarios How to get Date & Time values stored in your local time zone Layout & Styling Field Layout ...
Date and Time values in Form entries
Dates and times are captured as follows on form entries: Date only and Time only fields are captured in the local device time, but without any timezone information. As such, these are always displayed as the raw, local time values, without any time ...
What’s the difference between Form entry Completed time and Received time?
On the app side, the device's current date/time is used as the "Completed" date/time of the entry. This time is only as good as the device. So, if the device time is not accurate, then this will reflect on the Completed value as such. However, once ...
Importing Fields from Excel
When you need to create a big form with many questions, it can be time consuming to build all of these in our Form Designer. In most cases, the form that you are creating already exists as a Word or Excel file that is being printed out. That file ...