2 Replies Latest reply on Jul 17, 2014 6:20 AM by timacadia

    Adding Time



      Adding Time


           I'm trying to make a simple Appointment type calendar, nothing complicated,  You fill in the time and date and it shows on a portal on the main screen of our DB, we want to see easily when one of our people is at an appointment etc.

           I have time entry split into 3 fields, Hour, Min and Am or PM.   I also have a section for Drive time  (we bill different rates for drive time so it's essential we can easily see it)

           I want to be able to create a field that incorporates an Out of Office from\to   which incorporates the actual onsite times and the drive time  but when I run the script to do the calculation i get a gibberish answer??   any help

           Script is:    the first section that builds the time from the 3 sep numbers works fine, it's the subtraction of travel time that messes everything up

           TimeFr =

            (Calendar::TimeFrHR & ":" & Calendar::TimeFrMin & Calendar::TimFrAP) - 60 * Calendar::TravelTime


           so if we have TimeFrHR = 9 TimeFrMin = 15 TimeFrAP= AM   this sets TimeFr to 9:15AM perfectly as it should be

           however when i then add the - 60*Traveltime (which from what I searched before SHOULD subtract x mins from the time.    the field output becomes some gibberish number  For instance  If I set TravelTime  to 15  (being 15 mins)  the output instead of showing 9:00AM  becomes 0:00:15.  setting TravelTime to 25 makes the answer  -0:09:45

           TravelTime is a Number Field

           TimeFr is a Time Field

        • 1. Re: Adding Time

                    I have time entry split into 3 fields, Hour, Min and Am or PM

               Why not use a single field of type time? What do you gain by using separate fields?

               a calculation of Hour * 3600 + Min * 60 + 12 * 3600 * ( AmField = "PM" )

               with Time as the selected result type should work.

               Time fields are really number fields that record the number of seconds since midnight. (There are 3600 seconds in an hour)

          • 2. Re: Adding Time

                 Thanks PhilModJunk  works beautifully.


                 F.Y.I   i use 3 fields because it takes the guess work out of entering the time for the users. instead of trying to get them to enter the time as HH:MM AM or PM  I just have a drop down box for each Hr, Min and AM field, 1-12 for hour, 15, 30, 45, 00 for Min and AM or PM.  Accounts for not so bright employees