time sheet Calculate time
I am trying to calculate Total Hours in a Time sheet I created in Acrobat Pro. I found the script online to calculate hours between In and Out for the day but I am having two issues.
- If time is not entered in military format then the total for that day is incorrect. As long as I enter military format it gives me correct total.
- As you can see in line one in below screenshot I am getting correct total.
- Line two however is giving me -4:00 because my clock in time after lunch is 12:00 and out is 5:00.
- Line 3 shows time entered as military time.
- Issue number two. After I get the totals for each day in a time format then how to I add them up to get the total for the week?
- If I simply add the fields I get incorrect result. I am guessing because I am trying to add time which isn't same as decimal number.


This is the script I have in the total box for the day (T1). I have used same code for the remaining day totals and simply change the field names.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var nElapsed = ((this.getField("OutRow1").value * 60) + this.getField("OutRow1min").value) - ((this.getField("InRow1").value * 60) + this.getField("InRow1min").value)+
((this.getField("OutRow1_2").value * 60) + this.getField("OutRow1_2min").value) - ((this.getField("InRow1_2").value * 60) + this.getField("InRow1_2min").value);
// elapsed hours;
var nHrs = Math.floor(nElapsed / 60); // whole hours;
// elapsed minutes
var nMins = nElapsed % 60; // remainder minutes;
// format into hours and minutes;
event.value = util.printf("%,101.0f:%,102.0f", nHrs, nMins);
