6 Replies Latest reply on Dec 9, 2006 9:43 PM by JohnGree

    time increments

    JohnGree Level 1
      Hi i have a table called times

      which has a list of time ie 07:00, 07:10, 07:20 so on

      what i want is to let the user select a display start time ie 08:00 then select a time increment ie display every 10 mins

      not sure which is the best way to do this?

      any ideas
        • 1. Re: time increments
          Dan Bracuk Level 5
          For the selection time, I would use 2 dropdowns, one for the hours, one for the minutes. You could use one, but it would be a very long list.

          Use a text box for the time increment.

          When processing the form, turn the start time into a date-time object with some date so that you can apply date functions to it. Then write the code to achieve whatever it is you are trying to do.
          • 2. Re: time increments
            JohnGree Level 1
            ok many thanks

            so say i have start time of 08:00 and a increment of 40

            how would i code to display every 40 mins?
            • 3. Re: time increments
              Dan Bracuk Level 5
              Every 40 minutes for how long?
              • 4. Re: time increments
                JohnGree Level 1
                for every 40 mins that is in my table, so if my table of times goes til 9pm that would be the finish
                • 5. Re: time increments
                  Dan Bracuk Level 5
                  something like this

                  <cfloop condition = "StartTime lt EndTime">
                  <cfset StartTime = dateadd("n", form.increment, StartTime)>
                  closing tags
                  • 6. Re: time increments
                    JohnGree Level 1
                    ok thanks for that got it working, i am trying to populate a list box but the time it is showing is 1 hour ahead of what it should be

                    IN MY TABLE
                    GetUser.starttime = 08:00:00
                    GetUser.EndTime = 12:00:00
                    GetUser.Increment = 60

                    so in my list box it should show times 08:00 to 12:00 but it shows 09:00 to 01:00

                    any ideas why this is?

                    <select name="APPT_Time">
                    <cfset steptime = GetUser.starttime>
                    <cfloop condition="DateCompare(StepTime, GetUser.EndTime) LT 1">
                    <cfoutput query="GetUser">
                    <cfset StepTime = dateadd("n", GetUser.Increment, StepTime)>
                    <option value="#TimeFormat(StepTime, "hh:mm:ss")#">#TimeFormat(StepTime, "hh:mm")#