cancel
Showing results for 
Search instead for 
Did you mean: 

FormCalc Time Question

Former Member
0 Kudos

Hi,

i have to Time fields (starttime and endtime) for working hours. No im haveing a additional field which should include the total amount of hours and minutes.

for example:

Starttime = 1:30

Endtime = 2:45

........................

Time worked = 1.15 hours

................

what would be the formular to get the total worktime in FormCalc?

Accepted Solutions (1)

Accepted Solutions (1)

chintan_virani
Active Contributor
0 Kudos

Andreas,

I found similar thing on Adobe Forums and check if it helps you.

Set both of the fields startTime and EndTime to time/date fields. This way you can lock the way information is entered set the display validation and binding patteren to HH:MM then set the binding tab to time.

From here your final box can be a text field or a date field doesn't matter so much then the easiest way to do this in Livecycle is to use form calc on the total time field

Set the script to formcalc and place it under the calculation event.

if(startDate.isNull or endDate.isNull) \\ keep calculation clean
then
$ = 0 
else
$=Time2Num(startTime.formattedValue, "HH:MM") - Time2Num(endTime.formattedValue, "HH:MM")
endif

Former Member
0 Kudos

thank you so much for the replies guys. You made my day

I had to format my fields exactly like in my formCalc formula "HH:MM:SS".

My formula is now (its the first row of my table) working:

if(PDFArbeitsbericht.#subform.Subform1.Table3.Row1[0].ARBEITSENDE.isNull or PDFArbeitsbericht.#subform.Subform1.Table3.Row1[0].ARBEITSBEGINN.isNull)

then

PDFArbeitsbericht.#subform.Subform1.Table3.Row1[0].DateTimeField1 = ""

else

PDFArbeitsbericht.#subform.Subform1.Table3.Row1[0].DateTimeField1.rawValue = (Time2Num(PDFArbeitsbericht.#subform.Subform1.Table3.Row1[0].ARBEITSENDE.formattedValue, "HH:MM:SS") - Time2Num(PDFArbeitsbericht.#subform.Subform1.Table3.Row1[0].ARBEITSBEGINN.formattedValue, "HH:MM:SS")) / (60601000)

endif

Reps for you!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Andreas,

FormCalc provides date and time functions. Using these solves your problem in one line of code.

To calculate the working time you have to convert the time values to numbers (e.g. Time2Num). Do your calculation(s) and then convert the number back to a time value (e.g. Num2Time).

The reference for these functions is contained in Designer's help section under scripting there is a script reference.

Regards,

Juergen