on 06-19-2008 12:17 PM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.