2 Replies Latest reply on Jan 7, 2007 8:15 PM by RyanG24

    Time displaying worng

      Hi i have a list box which show increment time,

      starttime = 09:00
      endtime = 18:00
      Increment = 20

      so this should show 09:00 to 18:00 every 20 mins

      but i acually get 09:20 to 18:20

      any ideas why this is happening

      <select name="SMS_Time">
      <cfset steptime1 = GetUser.starttime>
      <cfloop condition="DateCompare(StepTime1, GetUser.EndTime) LT 1">
      <cfoutput query="GetUser">
      <cfset StepTime1 = dateadd("n", GetUser.Increment, StepTime1)>
      <option value="#TimeFormat(StepTime1, "HH:mm:ss")#">#TimeFormat(StepTime1, "HH:mm")#
        • 1. Re: Time displaying worng
          monkey_woo_too Level 1
          IYour code is wrong:
          1. why increment the time before you output it? that is why it starts outputting @ 9:20
          2. why cfoutput a query in the loop? what's the point?
          3. why do a dateCompare? Just use a straight numeric comparison.

          I think that this should work better. ( i haven't tested it though)

          <select name="SMS_Time">
          <cfset steptime1 = GetUser.starttime>
          <cfloop condition="StepTime1 lte GetUser.EndTime">
          <option value="#TimeFormat(StepTime1, "HH:mm:ss")#">#TimeFormat(StepTime1, "HH:mm")#</option>
          <cfset StepTime1 = dateadd("n", GetUser.Increment, StepTime1)>
          • 2. Re: Time displaying worng
            RyanG24 Level 1
            Hi thanks that solved the issue, but caused another on my action page

            The value "#TimeFormat(StepTime1," cannot be converted to a number
            The error occurred in D:\Websites\thecraxx\InetPub\wwwroot\SMS_Insert_Schedule.cfm: line 14

            12 : setLocale("English (Australian)");
            13 : smsDate=lsParseDateTime(form.SMS_Date);
            14 : hours=listFirst(SMS_Time,":")+listGetAt(SMS_Time,2,":")/60+listLast(SMS_Time,":")/360;
            15 : smsDate=dateAdd("h",hours,smsDate);
            16 : // shortcut method i forgot about