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

Need Help Building a Script for a Time Card

NileJackal
Registered: Jan 13 2010
Posts: 12
Answered

Hello,

I am currently a LiveCycle version 8.0 user. I am learning how to use FormCalc and Java and have had alot of good luck finding information in these forums or in my own studies when I hit a road block...thank you all!

However, I am currently facing a rather difficult one, and I blame myself for not fully understanding the functionality or syntax of FormCalc

I am building a Time Card for my company, and the project is almost complete. However I have hit a snag when it comes to calculating time. I have found several similar posts about this topic, but have not been able to find any indepth explanations.

What I need: I have four fields where employees will log there time in a "h:MM A" format. and a Total Hours Worked column. I understand that to calculate the time I will need to first convert the time into milliseconds using the Time2Num function. I am however unsure of the string formatting and how to get the function to pull the object value of the time enterd field. I tried the following way but i get the feeling its incorrect.

FormCalc Formula fo TotalTimeMonday Number Field:
Time2Num(MonLunchOut, "h:MM A")-
Time2Num(MonTimeIn, "h:MM A")+
Time2Num(MonTimeOut, "h:MM A")-
Time2Num(MonLunchIn, "h:MM A")
*60*60*1000

What am I missing or am I completely off the mark? Admittedly I am building off Excel Knowledge.

Similarly, on the same form, I am trying to get dates to populate automatically based on an indicated "End Date" how might i go about doing this?

Any help would be greatly appreciated! Thanks in advance!

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

read this thread.
It explains how to sum different times.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You need to make sure you are using the "formattedValue" value property.

To compute the fractional hours you need to divide by the number of milliseconds in an hour and not multiply by the number of milliseconds in an hour. You may also want to compute the time based on before lunch and after lunch times.

$.rawValue = 0if(HasValue(MonLunchOut) & HasValue(MonTimeIn)) then$.rawValue = $.rawValue + (Time2Num(MonLunchOut.formattedValue, "h:MM A") - Time2Num(MonTimeIn.formattedValue, "h:MM A")) / (60 * 60 * 1000)endif

 if(HasValue(MonLunchIn) & HasValue(MonTimeOut)) then$.rawValue = $.rawValue + (Time2Num(MonTimeOut.formattedValue, "h:MM A") - Time2Num(MonLunchIn.formattedValue, "h:MM A")) / (60 * 60 * 1000)else$.rawValue = $.rawValueendif

George Kaiser

NileJackal
Registered: Jan 13 2010
Posts: 12
Thank you that seemed to do it.

Thank you for clarifying too. This should go along way!