I have a script that was put together (courtesy of Masi). On occasion, one may work beyond 24 hours, ex; 27:00 hours. So far the script I have will calculate up to 24 hours without a problem. So in my time sheet that I have created I have three fields.
Time In
Time Out
Total hours
I have two additional fields
Date In
Date Out
Here is the script I have so far.
var vTime1 = timein.rawValue;
var vTime2 = timeout.rawValue;
if (vTime1.length == 4 && vTime2.length == 4) {
var vTime1Minutes = parseInt(vTime1.substring(0, 1))*600 + parseInt(vTime1.substring(1, 2))*60 + parseInt(vTime1.substring(2, 4));
var vTime2Minutes = parseInt(vTime2.substring(0, 1))*600 + parseInt(vTime2.substring(1, 2))*60 + parseInt(vTime2.substring(2, 4));
if (vTime1Minutes > vTime2Minutes)
vTime1 = vTime2Minutes+1440 - vTime1Minutes;
else
vTime1 = vTime2Minutes - vTime1Minutes;
}
var Hours = Math.floor(vTime1/60);
var Minutes = vTime1%60;
if (Hours == 0)
Hours = 24;
if (Hours <= 9)
Hours = "0" + Hours;
if (Minutes < 10)
Minutes = "0" + Minutes;
this.rawValue = Hours + ":" + Minutes;
(Above script courtesy of Masi)
So what is the script needed to calculate total hours between two different dates? I'm new at this and don't know how to write a script.
Cheers,
Jim Salo
check out this thread.
I posted a solution for the same purpose.
http://acrobatusers.com/forum/forms-livecycle-designer/pm-too-am-negative-value#comment-60234
radzmar
• LoveCycle Blog
Documents you need:
• LiveCycle Designer ES2 Docs