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

Subtraction in a PDF Form

dbemtit
Registered: Oct 6 2011
Posts: 2

Hello, my company currently uses a spreadsheet that I created in Excel for our time sheet. I am trying to convert this to an Adobe PDF Form using Adobe Acrobat X but I can't get the calculations to work. For example In time is listed in filed 7 Out time is listed in field 8 and total time is listed in field 9. I have the in and out fields formatted as time and the total field formatted as number. I try to put in the following code in box three:
 
field8-field7
 
The result is nothing, field 9 stays showing 0.0 with no error messages. Can anyone help?
 
Thanks!

My Product Information:
Acrobat Pro 10.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Acrobat Pro for Windows has 2 programs for crating forms, Acrobat and LiveCycle Designer. Acrobat is programed using JavaScript, LiveCycle Designer uses FormCalc and a different variation of JavaScript. Both however require the conversion of the time string to the number of milliseconds since the Epoch date.

Which program are you using to create your time sheet?

Have you written code to subtract numbers?

Think aobut how would you subtract character strings.


George Kaiser

dbemtit
Registered: Oct 6 2011
Posts: 2
The original time sheet was created in Excel and I opened Acrobat X Pro 10 and I clicked Create PDF Form and imported it. I have tried to calculate in the custom calculations but nothing has worked.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You need to convert the date time character string to a number.

Since you have not told exactly which program, Acrobat or LiveCycle Designer, you have created your form in, I will provide a general solution for each.

In Acrobat you can use the 'util.scand()' method to obtain the number of milliseconds from the Epoch date for the start and end. You can then subtract those numbers to get the difference in milliseconds. Now you can use division to convert the milliseconds to hours and minutes.

In LiveCycle Designer you can use the "Time2Num" function to obtain the number of milliseconds since the Epoch date for the start and end times. Simple subtraction of the times in milliseconds will give you the difference in milliseconds. Now some simple division will get you to the hours and minutes.

Acrobat examples:

Working with date and time in Acrobat JavaScript (Part 1 of 3) by Thom Parker
Working with date and time in Acrobat JavaScript (part 2 of 3) by Thom ParkerAdditional information in the Acrobat JS API Reference and LiveCycle Designer Scripting Referenced (look under the 'Help' menu option).

George Kaiser