Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1071
  • Last Modified:

Acrobat 7: LiveCycle Designer- Calculating Hours From Two Time Fields

I am designing a form for scheduling employees that has two fields, 'In', and 'Out'. A third field is used to calculate the difference in hours(example: 1.75 hours). I am having trouble getting the calculation to return hours instead of a pure number. When 'In'= 11:30 and 'Out'=12:30, for example, the difference is shown as '100', instead of '1'. Is there a way to accomplish what I need for this form?  Thank you.
0
frizzell
Asked:
frizzell
  • 2
  • 2
1 Solution
 
Karl Heinz KremerCommented:
What do you get for e.g. in=11:00 and out=12:35 ?

How are you calculating the diffrence?
0
 
frizzellAuthor Commented:
The time fields are 'In' and 'Out'. In the 'Hours' field, where I want the hours worked to be calculated, I use  'Out - In', using FormCalc. So, if Out='12:25' and In='11:00', the 'Hours' total shows as 135 instead of 1:35. If Out=5:00pm and In=11:00am, the Hours total shows as 600. The user enters the time in 24-hour format, ex: 1300 = 1pm. Thank you for your time.
0
 
Karl Heinz KremerCommented:
If you are interested in the number of hours, use something like this:

var difference = IsoTime2Num(Out) - IsoTime2Num(In);
difference / 1000 / 60 / 60;


The IsoTime2Num() function will convert the time (in 24h format) to milliseconds since the "epoch", so the subtraction of out and in times will leave you will milliseconds. The second line converts this value to hours.
0
 
frizzellAuthor Commented:
Thank you very much for the answer. It was EXACTLY the functionality that I needed. The speed and accuracy of your solution impressed me.
0
 
raulbrownCommented:
Hello
Very nice code.

The IsoTime2Num() function will convert the time (in 24h format) to milliseconds since the "epoch",
what if i want to convert the time in 12h format?
how will i go about it.

Thank you.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now