I had a lot of trouble with this too, thanks for the help. My solution also adds days for a leave form. The key for me was using the .formattedValue attribute and making sure the binding and value types for the time fields matched "HH:MM". My edit and display formats were "h:MM A".
on the exit event:
if ( HasValue(FromDate) and HasValue(ToDate) and HasValue(FromTime) and HasValue(ToTime) ) then
if ( FromDate == ToDate ) then
Total_Hours = 8 - ((Time2Num(FromTime.formattedValue, "h:MM A" ) - Time2Num("8:00 AM", "h:MM A" ) ) + ( Time2Num("5:00 PM", "h:MM A" ) - Time2Num(ToTime.formattedValue, "h:MM A" ) ) ) / (1000 * 60 * 60)
else
var PartialDayHours = ((Time2Num(FromTime.formattedValue, "h:MM A" ) - Time2Num("8:00 AM", "h:MM A" ) ) + ( Time2Num("5:00 PM", "h:MM A" ) - Time2Num(ToTime.formattedValue, "h:MM A" ) ) ) / (1000 * 60 * 60)
Total_Hours = 8 + 8 * ( Date2Num(ToDate, "YYYY-MM-DD") - Date2Num(FromDate, "YYYY-MM-DD") ) - PartialDayHours
endif
endif
Hope this saves somebody else some time...