3 Replies Latest reply on Aug 25, 2011 10:18 AM by philmodjunk

    Time Schedule Calculation

    CraigBarnes

      Title

      Time Schedule Calculation

      Post

      I am building a database of timepoints for bus routes. I want to put in the starting time in the first field, and have the remaining fields filled in automaticaaly based on adding minutes.

      Eample time points:

      • Lorene & 7th - Enter time manually (6:00 AM)
      • Dante & Venus - 15 minutes after previous (Lorene & 7th) (6:15 AM)
      • Transit Center - 15 minutes after previous (Dante & Venus) (6:30 AM)
      • Oro Grande - 25 minutes after Transit Center (6:55 AM)
      • Depart - 5 minutes after Oro Grande (7:00 AM - this would also become the next Lorene & 7th time))

      Then have the next Lorene & 7th time equal the previous Depart time.

      Want to start this at 6:00 AM and have one every hour until 8:00 PM. Or repeat until a certain hour or number of times.

      Thanks in advance,

      Craig

        • 1. Re: Time Schedule Calculation
          philmodjunk

          Define a time field as "StartTime".

          Define a number field as "ElapsedTime"

          Define, cArrivalTime as a field of type calculation with this expression:

          StartTime + If ( Get (RecordNumber) > 1 ; GetNthRecord ( cArrivalTime ; Get (RecordNumber ) - 1 ) + ElapsedTime * 60 )

          To define this calculation, you have to do it in two steps. First enter/select "StartTime", then click OK to close Specify Calculation. Click options to re-open Specify Calculation and continue adding the rest of this expression. (That extra step puts cArrivalTime into the list of fields so that you can include it in the calculation.)

          Select Time as this calculation field's return type.

          You start by creating a record and entering a start time, leaving ElapsedTime empty.

          Then create additional records for each bus stop, entering just an elapsed time, leaving start time empty.

          Want to start this at 6:00 AM and have one every hour until 8:00 PM. Or repeat until a certain hour or number of times.

          You'll have to explain what you want on that in more detail. I don't know exactly what you have in mind for that.

          • 2. Re: Time Schedule Calculation
            CraigBarnes

            Thanks, that does the trick, but when I start a new line, it adds to the previous time. The new line should be separate. I've attached a screen shot for reference.

            Screen Shot

            • 3. Re: Time Schedule Calculation
              philmodjunk

              Yes, as written, you'd need to limit your found set to just one bus schedule at a time.

              This expression should work for multiple schedules in one found set (but be careful how you sort these records...)

              If ( StartTime ; StartTime ; If ( Get (RecordNumber) > 1 ; GetNthRecord ( cArrivalTime ; Get (RecordNumber ) - 1 ) + ElapsedTime * 60 ) )