Link to home
Start Free TrialLog in
Avatar of NCSO
NCSO

asked on

Adobe LiveCycle how to calculate time difference

I have a livecycle form with two time fields and a textbox; I am trying to do a calculation between the two time fields.  I have the following code in the formCalc but it will not calculate:

// get end time in milliseconds from the Epoch date
var EndTime = Time2Num(SatTimeOut1.formattedValue, "HH:MM")
// get start time in milliseconds from Epoch date
var StartTime = Time2Num(SatTimeIn1.formattedValue, "HH:MM")
// compute difference in milliseconds
var Diff = EndTime - StartTime
// difference in seconds
Diff = Diff / 1000
// difference in minutes
var Minutes = Diff / 60
// difference in hours
var Hours = Minutes / 60
// Get whole hours only
Hours = Floor(Hours)
// Get minutes only (modulo 60 of minutes)
Minutes = Mod(Minutes, 60)
// format the result
Concat(Hours, ":", Format("99", Minutes))

When I preview the PDF is shows 0:00 in the text field no matter what value is entered in the time fields.

Any help would be greatly appreciated...
ASKER CERTIFIED SOLUTION
Avatar of puppydogbuddy
puppydogbuddy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of puppydogbuddy
puppydogbuddy

oops! You don't need to use the TimeDiff function.  You just need the Time2Num() function to compute the time differential.
Avatar of NCSO

ASKER

Many Thanks!  Great to have a resolution...
I tried puppydogbuddy's scripts but still got 0:00 no matter what I entered in the time fields. Could anyone please help? Thanks!