Home > WebEOC > Admin Guide > Board Building Tips > Calculate Hours Elapsed Between Fields

Calculate Hours Elapsed Between Fields

Table of contents
No headers

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.

Note: The example uses time1 and time2 as the date fields. You will need to change these to match your field names.

(Whole Number Hours)

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

(Hours and Minutes)

<expression name="diffhours"> 
cast(cast(datediff(n,dbo.convert2Local(time1,@TIMEZONE,@DAYLIGHT),dbo.convert2Local(time2,@TIMEZONE,@DAYLIGHT)) as float) / 60 as decimal(10,2)) 
You must to post a comment.
Last modified



This page has no classifications.