Expand my Community achievements bar.

Time2Num

Avatar

Former Community Member
Does anyone know how to use Time2Num to determine the time difference?



I have tried the following FormCalc in "calculate" with variations of "HH:MM:SS" and anything I do yields a calculation result of "0".



if (HasValue(timein) and HasValue(timeout)) then

$ = (Time2Num(timeout,"H:MM A") - Time2Num(timein,"H:MM A"))

else $ = null

endif



What am I missing? Please?
8 Replies

Avatar

Former Community Member
Chris,



I have tested an example of Time2Num and this is what I did and I yielded a result:



1) I created 2 Date/Time fields (each with the display pattern set to HH:MM:SS, the data format set to Time and the data pattern set to HH:MM:SS), and 1 Numeric Field.



2) For testing in the DateTimeField1, I placed the following script in the initialize: $ = "13:13:13", and I placed $ = "13:13:19" in DateTimeField2 on the initialize.



3) In the NumericField I placed the following code on the calculate event:

$ = (Time2Num(DateTimeField2,"HH:MM:SS") - Time2Num(DateTimeField1,"HH:MM:SS"))



When I ran it, the numeric field displayed 6000 for me, which if divided by 1000 is 6 sec, which is the difference between the 2 values.



I hope this helps, the rest of the code should follow once you have the Time2Num function working.



Catherine

Avatar

Former Community Member
i am trying to use this time2num function. following your test example why do u need to put a script in for the 2 date/time fields? i guess i am confused.



i need help. thanks

Avatar

Former Community Member
what i mean is i don't know how to use the initialize funcation really. yes, i tried your test example and it worked but how do i let the user enter any number they need without entering it into the initialize script everytime - sorry i am new to designer.

Avatar

Former Community Member
Hi Colleen,



I placed the initialization in to demonstrate the functionality of Time2Num. You would want the users to enter this information when filling in the form.



Hope that helps,



Catherine

Adobe Systems

Avatar

Former Community Member
yes, i understand but when i put the script in for the numeric field - the calculation doesn't work. i don't know what else needs to be done to make it work. sorry - i', confused. do i ned to have a script in the date/time fields also and if so then what? thanks

Avatar

Former Community Member
Colleen,



Use formattedValue DateTimeField2.formattedValue instead of the field name DateTimeField2 in your calculation, it should then work.



Here is a working example.



http://66.34.186.88/LiveCycleSamples/.3bbd9bc1.pdf

Avatar

Former Community Member
now, i have a new issue!! my form and calculation works in designer but NOT in Adobe Reader or Acrobat. how can this be?