Double-check the parentheses in the last line.
What is the formatting of the field?
// Start Time
var v1 = getField("Text1").value;
// Finish Time
var v2 = getField("Text2").value;
var v3 = getField("Text3").value;
// Total Hours
event.value = v2 - v1 - v3;
if(parseInt(event.value < 0 )) event.value = (parseInt(event.value) + 12).toString();
console.println("v1: " + v1);
console.println("type of v1: " + typeof v1);
console.println("v2: " + v2);
console.println("type of v2: " + typeof v2);
console.println("v3: " + v3);
console.println("type of v3: " + typeof v3);
Using civilian 24 hour time format for the fields, I get the following result:
type of v1: string
type of v2: string
type of v3: string
The calculation results in a NaN value.
Hi I inputed that script and got this from the console:
type of v1: number
type of v2: number
type of v3: number
I want it to be treated as numbers as this is for calculating total hours. I'm very novice at this sorry if I haven't made myself clear.
P.S. The whole point of the +12 part is so that when people do not input their time in 24 hour time.
Most people fill in time sheets with either the hours worked in a day or the time string in a standard format for the start and end times.
"8" is not military time. It should be 0800 or zero eight hundred hours.