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

Time Calculations Using FormCalc in Livecycle Designer

Niraj
Registered: Jun 10 2010
Posts: 2

I am only recently got the live cycle designer version 8.2 and tying to create a Timesheet for my staff.

I want to calculate the no. of hours after the end user inputs the Start Time and the End Time. And Finally the sum up the whole Thing to know total daily hours and ultimately weekly hours.

I tried Doing the following

My First Field is " From " where the enduser needs to input the Start time of the job
My Second Field is " To " where the enduser needs to input the end time of the job
My Third Field is " Total " where the difference between the start time and end time is calcuated and displayed in HOURS and MINUTES i.e. HH:MM.

From various different post I wrote the following code in the " Total " which is also a date/time field.

(Time2Num(To,"H:MM") - Time2Num(From,"H:MM"))/(3600000) but some how it calculates only integral hours i.e. it shows difference between 12.00 and 13.00 as 1

But

doesn't give difference between say 12.34 and 16.54 as 4.20.

Please help and it is quite urgent.

Thank in advance.

Niraj Shah

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can not use the 'Time2Num' function since this converts to the actual time. Your difference if is the time from midnight. Not the elapsed time. You would need to write some FormCalc or JavaScript to convert the milliseconds into a formatted string of hours, minutes, seconds as needed.
// compute elapsed timevar elapsed = (Time2Num(To.formattedValue, "H:MM A") - Time2Num(From.formattedValue, "H:MM A")) / (1000 * 60)// compute whole hours, format as string and trim leading spacesvar Hrs =  Ltrim(Str(Floor(elapsed / 60)))// compute remainder minutes, convert to string, remove leading blanks, // pad leading zero, make string 2 character longvar Mins = Right(Concat("0", Ltrim(Str(Mod(elapsed, 60)))), 2)// create formatted display stringConcat (Hrs, ":", Mins)

George Kaiser