These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Timesheet Calculations

mermaidlisa
Registered: Jan 31 2008
Posts: 7
Answered

I am having some problems with figuring out the formula for a timesheet.
If an employee puts in box 1 that they worked 1 hour and 30 minutes
then in box 2 they worked 1 hour and 30 minutes, I need the total hours worked to come out to 3 hours.
I hear it's hard to do this with a date/time box, is there a way for me to tell a numeric box to enter time as a decimal and to round .59 minutes to 1.00?
If so how do I do that?

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
A LiveCycle date/time field returns a formatted date/time string. In your case , if you are just dealing with hours and minutes, you can add up time in different fields by

1. parsing the formatted string for the hours and minutes information,
2. Converting this in to seconds.
3. Adding up the seconds for all the fields
4. dividing total seconds by 3600 to get Total hours.
5. Keep the remainder seconds and divide it by 60 to get minutes

If you need to deal with weeks or dates, then you'll need to use the JavaScript Date object

Working with dates and times is pretty easy if you know how it all works. See this artical. It has several sample files.

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/date_time_part1/

The files are not LiveCycle forms, but the time calculations are the same for all JavaScript, regardless of the environment.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

dk3dknight
Registered: Jan 22 2008
Posts: 136
There is a way to round decimals up or down with formcalc.

Sum(Round(DayHrs1+NightHrs1, "abc"))

DayHrs1 = First time
NightHrs1= Second time

"abc" = leave no decimal.

It will round up anything .5 and up
It will round down anything less then .5

That might not be the exact solution you wanted, but that does work
with numeric boxes and it does get you to your whole hour.

Course a few people might be upset that they lost a few minutes.

What this is, is a Sum and a Round Calculation.
mermaidlisa
Registered: Jan 31 2008
Posts: 7
I will try this sample but it can't round down nor lose a few minutes because everything does have to be exact. instead of using date/time there should be a way to do this with a numeric text.
dk3dknight
Registered: Jan 22 2008
Posts: 136
Ive been thinking replace abc with 1 and see if that makes a difference.
mermaidlisa
Registered: Jan 31 2008
Posts: 7
Changing "abc" to "1" didn't round .6 to 1.00
when I out in 1.33 (one hour 33 minutes) in day 1 and 1.33 into day2 the sum came out to be 2.7 instead of 3.06 (three hours and 6 minutes).
There has to be away to tell the program that after .59 everything else gets round to 1.00
dk3dknight
Registered: Jan 22 2008
Posts: 136
How about scraping the round and instead do a sum and a division by having the user only put in the minutes.

such as 320 minutes, 100 minutes... = 420 minutes / 60 = Hours and minutes.
mermaidlisa
Registered: Jan 31 2008
Posts: 7
Thanks for the help with what everyone suggested I was able to get the formula to work. My last newbie question is: I created this form in lifecycle but when others want to sae the document they can't, is there a way to do this?
dk3dknight
Registered: Jan 22 2008
Posts: 136
This is actually a very simple question.

What you need to do is open your form up
in Adobe Pro, go to the top menu and look for
Advanced -> Enable Usage Rights in Adobe Reader.This is necessary for allowing regular reader folk to save
the document.

It will have you save the document, this document it saves
is acrobat reader friendly but it add limitations on redesigns.

If accidentally save over your original, going to File->Save a copy,
will allow you to save it back without reader rights.

Hope that helps.
mermaidlisa
Registered: Jan 31 2008
Posts: 7
I have Adobe professional 7.0 and am not finding the enable usage rights under the advanced tab.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Currently, the only version of Acrobat Professional that can enable Extended Reader Rights is version 8.

George Kaiser

dk3dknight
Registered: Jan 22 2008
Posts: 136
Eeek I don't have a copy of 7, that feature I gave was for 8 pro ,sorry.