Calculate Hours Elapsed Between Fields

To calculate the time that has elapsed between two date fields, ensure you have two fields where the value="currenttime" and validates as time.

For example, <input type="text" name="time1" size="15" validate="time" value="currenttime" required=""/> and <input type="text" name="time2" size="15" validate="time" value="_currenttime" required=""/> would both work.

If this applies, use the following expressions to calculate the number of hours that have elapsed between two date fields.

The example uses time1 and time2 as the date fields. Change these to match your field names.

(Whole Number Hours)

Copy Code
<expression name="diffhours">datediff(hh,dbo.convert2Local(time1,@TIMEZONE,@DAYLIGHT),dbo.convert2Local(time2,@TIMEZONE,@DAYLIGHT))</expression>

(Hours and Minutes)

Copy Code
<expression name="diffhours">
cast(cast(datediff(n,dbo.convert2Local(time1,@TIMEZONE,@DAYLIGHT),dbo.convert2Local(time2,@TIMEZONE,@DAYLIGHT)) as float) / 60 as decimal(10,2))
</expression>