Hey everyone, I'm pretty green when it comes to this stuff but I'm trying to figure this out so I'm reaching out here. I'm trying to develop an equation in FormCalc that will calculate the difference, in hours, between two times. The times will be entered in GMT and I have the equation below, so far, that works but the problem is when the second (OFF_DUTY_TIME) is beyond 24:00, such as 02:30. Any insights or suggestions?
What I have so far:
if (HasValue (OFF_DUTY_TIME) and HasValue (ON_DUTY_TIME)) then (Time2Num(OFF_DUTY_TIME.formattedValue, "HH:MM") - Time2Num(ON_DUTY_TIME.formattedValue, "HH:MM")) / (60 * 60 * 1000) endif
Ok, so I changed it up to the equation below, but now if the difference is calculated between two times on the same day (GMT), it is one minute off. But if the difference is between two times on different 'days' (once again, all times GMT), it is correct. Any advice?
var startT = ON_DUTY_TIME.formattedValue
var endT = OFF_DUTY_TIME.formattedValue
var differenceT = Time2Num(endT, "HH:MM") - Time2Num(startT, "HH:MM")