Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Calculating Time

Avatar

Avatar
Validate 10
Level 2
Gene--O
Level 2

Likes

3 likes

Total Posts

76 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
Gene--O
Level 2

Likes

3 likes

Total Posts

76 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
View profile
Gene--O
Level 2

30-06-2010

Good Afternoon All,

I am creating a timesheet that covers a two week period. I have a table set up with the following fields:

TimeIn1, TimeOut1, TimeIn2, TimeOut2, Total Hours, OT Hours

The user will input their times for the morning (TimeIn1 and TimeOut1) and then the afternoon (TimeIn2 and TimOut2) for each day. I need the Timesheet to calculate how many hours were worked in that day. I would like it to round to the nearest quarter hour. At the end of the week, I need the form to add how many hours were worked for the week, and place any hours over 40 into the "OT Hours" field.

I am VERY limited in FormCalc and Javascript, so if you reply, PLEASE try to explain to me what you have done!

Thank you!!!!

Gene-O

View Entire Topic

Avatar

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile

Avatar
Validate 1
Level 10
Niall_O_Donovan
Level 10

Likes

646 likes

Total Posts

4,352 posts

Correct Reply

786 solutions
Top badges earned
Validate 1
Boost 500
Boost 50
Boost 5
Boost 3
View profile
Niall_O_Donovan
Level 10

01-07-2010

Hi Gene-O,

Here is a sample: https://acrobat.com/#d=kCPIgVkd09qrx6h-WRXxbQ

It is all FormCalc and the script is in three locations. The daily hours field has a basic check to see that the fields are not null and that the In time is before the Out time. The total normal hours does a basis addition of the daily totals and then checks if this is greater than 40hrs. If it is, then it limits the normal hours to 40hrs and spills the rest into overtime hours. The last script is in the total hours field that basically adds the normal and total hours together.

The only function used is Time2Num, which converts the inputted time into a number. This allows you subtract times. The time is in milliseconds so dividing by (60 * 60 * 1000), converts it back to hours.

The time function is tricky, if the user does not input a time correctly, the function will return "0". I have tried to capture this in a validation script.

Hope that gives a direction.

Niall