Expand my Community achievements bar.

## Time In/Time Out/ Total Time Question

Level 2

How do you get to calculate 2:00pm minus 12:30 pm to a total time of 1.5 hours??? Please HELP!

8 Replies

Level 7

You would use the Time2Num function to change the times into numbers and then minus one from the other. It gives the number in milliseconds so you would then divide the final number to give hours. You just have to make sure the times are entered using a specific pattern.

Former Community Member

How do I properly add a date field object into a new form?  The "getting started" tutorial tells me to drag an object called "date field" from the standard section of the object library, but no such object actually exists.  I instead used the "date/time" object, but it simply provided a text field rather than a clickable calendar.  How do I get around this?  I apologize for posting this question here, but the forums are not providing me with an option to create a new threat.  Thank you.

Level 7

the date/time field is the calendar. It looks like a text field but if you go to preview and click on it you will see that the arrow comes up to activate the calendar. You can also just type text into it. You can set it to just date or time in the Object > Binding tab.

Level 2

Hi Whyisthisme, and thank you for your response.

I have tried unsuccesfully to use the function Time2Num. If you can post a working sample code would be great.

Thank you!

Jessica

Level 10

Hi,

this topic was discussed already several times, so will many find examples when you use the forums search.

Former Community Member

Thank you so much!  It worked.

Level 2

Thank you for the sample, it is very helpful. I do have a question...

the time fields patterns are: time{hh:MM A}, however, when calculating timein: 02:00 pm MINUS timeout: 02:15 pm it dispays a total of 21.25 hours. All am calculations seem to be fine, all pm calculations are not.

Current formula is:

Time2Num(timeout, "HH:MM")/ (1000 * 60 * 60)-Time2Num(timein, "HH:MM")/ (1000 * 60 * 60)

In all your examples I noticed you using the FormattedValue used after fields names like timein and timeout. When using this function the total hours displays zero.

Any suggestions how to fix this?

Level 10

Hi,

if you use other display patterns than in my sample script, you have to modify the script, so it will recognise the formatted values correctly.

For the display pattern time{hh:MM A} modify the script into:

`Time2Num(timeout, "hh:MM A")/ (1000 * 60 * 60)-Time2Num(timein, "hh:MM A")/ (1000 * 60 * 60)`