how to calculate the difference between 2 time fields in adobe livecycle

how to calculate the difference between 2 time fields in adobe livecycle..i need to show difference in another box. please help me


rajendran kumar


2 Answers

Voted Best Answer

Hi every body i got answer .

This is the script to find duration between start time and end time.

if (HasValue(StartTime) and HasValue(EndTime))thenvar in_ = Time2Num(StartTime.formattedValue, "HH:MM:SS")var out_ = Time2Num(EndTime.formattedValue, "HH:MM:SS")if (in_ >= out_) thenxfa.host.messageBox("The start time cannot be greater than or equal to the end time.")this.rawValue = null
else
var diff = out_ - in_this.rawValue = diff/3600000
endif
elsethis.rawValue = nullendif


By rajendran kumar   

The answer seems overly complicated.
Using a From, To and Total date/time fields set to time input.

In the Total field enter FormCalc script as below:
var startTime = Time2Num(From.formattedValue, "HH:MM")var finishTime = Time2Num(To.formattedValue, "HH:MM")var total = Num2Time(Total.formattedValue, "HH:MM")(finishTime - startTime) / 3600000

The answer is in minutes.

Set the Display and Edit patterns to 'time{HH:MM}' for each field (without quotes). It wont calculate correctly if the finish time is before the start time. Eg: From 15:00 To 00:30 won't give the right answer. A date would need to be added to calculate it properly.


Duncan Waugh   


Please specify a reason: