Copy link to clipboard
Copied
Hi all,
I am new to using adobe acrobat and am very confused. I want to convert and old timesheet that had been made in excel into a fillible form on adobe acrobat. I am having trouble with the calulations for the total hours (military time). In excel the sheet calculates using the formula under the hours cell is =MOD(G8-F8,1) where G8 is time out and F8 is time in. How would I do this in adobe so that I get the same result?
All I want is a simple time in, time out, and total hours, and I want to make sure it can calculate if the times go beyond midnight.
I would appreciate as much info as I can get, thanks!
I actually found the answer in a different post! Thanks to try67, kudos to you!! The only difference is that in my script I had "TimeInRow1" instead of "Time 3.1" and "TimeOutRow1" for "Time 4.1". Hope this is helpful for anyone that needs!!
var start = this.getField("Time 3.1").valueAsString;
var finish = this.getField("Time 4.1").valueAsString;
if (start=="" || finish=="") event.value = "";
else {
var startArr = start.split(":") ;
var finishArr = finish.split(":") ;
var hourDiff = finishAr
...
Copy link to clipboard
Copied
I've moved this from the Using the Community forum (which is the forum for issues using the forums) to the Acrobat forum so that proper help can be offered.
Copy link to clipboard
Copied
I actually found the answer in a different post! Thanks to try67, kudos to you!! The only difference is that in my script I had "TimeInRow1" instead of "Time 3.1" and "TimeOutRow1" for "Time 4.1". Hope this is helpful for anyone that needs!!
var start = this.getField("Time 3.1").valueAsString;
var finish = this.getField("Time 4.1").valueAsString;
if (start=="" || finish=="") event.value = "";
else {
var startArr = start.split(":") ;
var finishArr = finish.split(":") ;
var hourDiff = finishArr[0] - startArr[0];
var minDiff = Math.floor(((finishArr[1] - startArr[1]) / 60)*100);
if (minDiff<0) {hourDiff--; minDiff += 100;}
if (hourDiff<0) hourDiff+=24;
if (minDiff.toString().length == 1) minDiff = '0' + minDiff;
event.value = hourDiff + "." + minDiff;
}
Copy link to clipboard
Copied
Just a tip, not sure what format you need, but for example lets say time diff is 7h and 30min, the above code will give you 7.50 instead of 7:30.
Copy link to clipboard
Copied
How to solve this problem? Thanks @Asim123
Copy link to clipboard
Copied
Change these lines:
if (minDiff.toString().length == 1) minDiff = '0' + minDiff;
event.value = hourDiff + "." + minDiff;
To:
event.value = (hourDiff + minDiff/60).toFixed(2);
Copy link to clipboard
Copied
This line is incorrect:
if (minDiff<0) {hourDiff--; minDiff += 100;}
It needs to be:
if (minDiff<0) {hourDiff--; minDiff += 60;}
Copy link to clipboard
Copied
What column formats did you use?
Hours, numbers, text only..?