I am trying to create a form for a work schedule. I have two fields "time in" and "time out" and the third field is the total hours field - all in military time. And I want to calulate if the difference between the times is less than 6 hours then no break, if 7 hours then 30 minute break (minus 0.5 hours), and if greater than 8 hours then one hour lunch. So the total hour field of a shift from 1200 to 2100 is 8 hours.
Thanks in advance
I've got this so far and it seems to work up until it hits 8 hour shift which it should calculate 7 hours but only shows 6.5. And anything greater than 8 also shows 6.5. What am i doing wrong?
var nH1 = this.getField('T2').value - this.getField('T1').value;
if( nH1 <= 6 ) event.value = nH1;
else if( nH1 = 7 ) event.value = nH1 - 0.5;
else if( nH1 >= 8 ) event.value = nH1 - 1;
where T1 is time in
T2 is time out
H1 is total hours
Europe, Middle East and Africa