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

Posted on 2005-04-07
Last Modified: 2012-08-14
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.
Question by:frizzell
    LVL 44

    Expert Comment

    by:Karl Heinz Kremer
    What do you get for e.g. in=11:00 and out=12:35 ?

    How are you calculating the diffrence?

    Author Comment

    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.
    LVL 44

    Accepted Solution

    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.

    Author Comment

    Thank you very much for the answer. It was EXACTLY the functionality that I needed. The speed and accuracy of your solution impressed me.

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Can Be Caused By Disabled Services I have encountered a problem viewing PDF files using Adobe Acrobat Reader.  For the longest time, PDFs might launch or might not.  Sometimes they took about 15 minutes to appear after launching them. After som…
    This article is in response to a question here ( at Experts Exchange. The Original Poster has a scanned signature and wants to make the background transparent so that the signature may be pl…
    In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
    In this second video of the Xpdf series, we discuss and demonstrate the PDFimages utility, which, in a single command, is able to extract all the images from a PDF file and save each one in a separate image file (PBM, PPM, or JPG). Download and inst…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now