Expand my Community achievements bar.

SOLVED

calculating times in a form

Avatar

Former Community Member

I have a Form i cant figure out how to calculate times i have 6 boxes i need to put times into and the 7th box would be the total time.

this form is used at our fire dept to show the trucks en-route -to- on scene time- to- scene secure -to- left scene -to- in service time.. and then the total time in the final box i believe you just subtract the enroute time from the total time. but i have no idea i tried everything and cant figure it out.  i can upload the form if you need.

THANKS

1 Accepted Solution

Avatar

Correct answer by
Level 6

I've attached an updated version of your form.

Time calculations are always a little tricky, and it's one of the areas that I wish Adobe would handle a little better.  In this case I've assumed that you are using 24-hour time formats.  Calculating the difference is a little tricky, since your runs can span midnight and the end time value will be smaller than the start time.  The easiest method is pretty unsophisticated: calculate the hours and minutes separately, and adjust if the times span midnight.

In the attached form I've done the first column for you.  There is new javascript in the TotalTime910 cell Calculate event.  You should be able to copy that script and paste it into the Calculate event for the other TotalTime cells; the only change that you'll need to make is to change where the startTime and endTime values are extracted.  For example, for the TotalTime911 cell you'll use the Row2.enroute911 and Row6.InService911 fields.

Remember to change the Language dropdown to JavaScript when you paste into each event.

Also, I changed the cell patterns for the cells in the 910 column to: null{}|num{9999}.  This will display the values in proper 24-hour format, e.g. 0200 for 2am.  If that works for you, copy the pattern to the other cells in the table.  I eliminated the zero{} pattern since it causes midnight to be displayed as a blank; it should be displayed as 0000.

Finally, this all falls apart if you're on-scene longer than 24 hours. In that case you'll need dates as well as times to make it work.  Hopefully nothing in your city will burn that long.

View solution in original post

16 Replies

Avatar

Former Community Member

Here is the file up top under the vechile i need caluculated for all the vechile in time format

Avatar

Former Community Member

Anyone have any luck helping me out or any ideas i would really appreciate it

Avatar

Correct answer by
Level 6

I've attached an updated version of your form.

Time calculations are always a little tricky, and it's one of the areas that I wish Adobe would handle a little better.  In this case I've assumed that you are using 24-hour time formats.  Calculating the difference is a little tricky, since your runs can span midnight and the end time value will be smaller than the start time.  The easiest method is pretty unsophisticated: calculate the hours and minutes separately, and adjust if the times span midnight.

In the attached form I've done the first column for you.  There is new javascript in the TotalTime910 cell Calculate event.  You should be able to copy that script and paste it into the Calculate event for the other TotalTime cells; the only change that you'll need to make is to change where the startTime and endTime values are extracted.  For example, for the TotalTime911 cell you'll use the Row2.enroute911 and Row6.InService911 fields.

Remember to change the Language dropdown to JavaScript when you paste into each event.

Also, I changed the cell patterns for the cells in the 910 column to: null{}|num{9999}.  This will display the values in proper 24-hour format, e.g. 0200 for 2am.  If that works for you, copy the pattern to the other cells in the table.  I eliminated the zero{} pattern since it causes midnight to be displayed as a blank; it should be displayed as 0000.

Finally, this all falls apart if you're on-scene longer than 24 hours. In that case you'll need dates as well as times to make it work.  Hopefully nothing in your city will burn that long.

Avatar

Former Community Member

Thank you so much Kevin your the best ever...i havent messed with the other fields yet but i will try but i love how yours works so great thank you very much and thanks for replying back and i hope nothing burns down over 24 hrs hahaha

another quick question.....you see where i have the date/time field up in the left corner and you can click on the arrow on the right of that field to get the calander for the date i like that... is thee anyway i can get the time in that field too or in a new field a time that doesnt count but when you click on that box it displays the current time stays that time ??

THANKS FOR EVERYTHING AND ALL YOUR HARD WORK

Avatar

Former Community Member

Kevin

I did everything like you said but i cant get the total field to calculate.. i went into object and values and its blank on the one you did but mine isnt blank it says calucate only or somthing maybe that is stopping the calulation?? would you please let me know..

Nick

Avatar

Level 6

In the copy I sent you, the Value for TotalTime910 was set to Type: Calculated - Read Only and the Calculation Script radio button was selected.  The other TotalTimexxx fields were set to Type: User Entered - Optional.  They should all be set to Calculated, and the Calculation Script button should be selected.  If that doesn't work for you, post the form again and I'll take another look.

Avatar

Former Community Member

Kevin

I dont know where im going wrong at i tried it and still no go... i went though and changed all the patterns in the feilds i just need to add the scripted to the rest of the total fields... i wish i knew how to do it if i have to make another form in the future but here it is for you thanks for everything you dont for me.

Avatar

Former Community Member

another quick question.....you see where i have the date/time field up in the left corner and you can click on the arrow on the right of that field to get the calander for the date i like that... is thee anyway i can get the time in that field too or in a new field a time that doesnt count but when you click on that box it displays the current time stays that time ??

Avatar

Level 6

Ok, I see the issue.  Case matters when specifying field names.  For the first column, the cell is named "enroute910".  The other columns have an upper case E, e.g. "Enroute911".  When you paste the code and change the field names up top, make sure the names match exactly, including upper/lower case.

For your question about the time: do you want it so that when you select a date, the current time automatically populates a box next to the date?

Avatar

Former Community Member

ok ill try that

For the time yeah thats sounds good but i dont want the time to change i want it when you pick the date the time pops up and stays that time instead of the time counting and changing

Avatar

Former Community Member

Hey Kevin

I got everything to work and it works great thanks again

any luck on the time thing?

Avatar

Level 6

So if they choose a date and the time fills in, then they choose a different date, the time will not change?  Or will it reinitialize to the new current time?

Also, is your form extended so that it can be saved, or do the users just fill out the form and print it?

Avatar

Former Community Member

RIGHT I HAvE THE DATE FIELD UP THERE ON THE LEFT WITH THE CALAMDER. I WOULD LIKE ONCE THEY PICK A DATE THE CURRENT TIME COMES UP AND STAYS THE TIME WHEN IT WAS FIRST SELECTED.  I DONTT WANT A TIME THAT KEEPS COUNTING LIKE THE COMPUTER TIME SO ITSIT'S LIKE WE HAVE A TIME RECORD WHEN THE FORM WAS FILLED OUT BUT I DONT WANT THEM TO CHANGE THE TIME.  MAKE ANY SENSE OR AM I CONFUSING YOU.  AND YES ITSIT'S EXTENDED WHERE IT WILL BE SAVED

Avatar

Level 1

I do not have Adobe LifeCycle.  I just have Acrobat Pro. I wanted to create a calculation to take my Start Time, End time, and give me the total Regular Hours and Overtime Hours worked (End Time - Start Time; for anything above 08:00 hours place in Overtime Column. Then I wanted to total the Regular Hours and the Over Time Hours and reach Total Hours.

The only simple calculation I can do is Sum columns, and it will not do it if I have format my columns with a HH:MM time format.

Please help.   I need to create my own Payroll/Time Sheet to submit to my contractor so he and I can digitally sign it every week when I submit my time card.

Avatar

Level 1

any chance you could email me that form. I am working on the same thing for my fire department. jpratt@mcrfd.org Nickp223