These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Adding Hours

John864
Registered: Nov 16 2010
Posts: 19
Answered

Hi,
 
I am subtracting one time from another with the code attached. However I now want to total a number of these subsequent calcualtions. I am getting an error when i try to total all these hours. The code actually refers to a change I need to make to the code (change to 'event value') but I can't seem to get it to work.
 
can you anyone show me the change I need?
 
cheers
 

My Product Information:
Acrobat Pro 9.0, Windows
John864
Registered: Nov 16 2010
Posts: 19
Accepted Answer
sorry - code attached....

// Time Values
var cStartTime = this.getField("Dropdown11M").value;
var cEndTime = this.getField("Dropdown12M").value;

// Only process if field contains a value
if((cStartTime != "") && (cEndTime != ""))
{
// Convert to Hours Decimal value
var aStartTime = cStartTime.split(":");
var nStartTime = Number(aStartTime[0]) + Number(aStartTime[1])/60;
var aEndTime = cEndTime.split(":");
var nEndTime = Number(aEndTime[0]) + Number(aEndTime[1])/60;

// Find Difference
var nTimeDiff = nEndTime - nStartTime;
var nHours = Math.floor(nTimeDiff );
var nMinutes = Math.floor((nTimeDiff - nHours)*60 + 0.5);


// If used in a calculation, may need to be changed to "event.value ="

this.getField("TH1M").value = util.printf("%02d:%02d",nHours,nMinutes);

}
else
this.getField("TH1M").value = "";