3 Replies Latest reply on Mar 18, 2007 5:15 AM by JohnGree

    cycle problem

    JohnGree Level 1
      ok i have cycle problem hope someone can help me

      the user will pick from the following

      Date: 12/10/2007
      Time: 09:00
      Frequency: monthly
      Cycles: 12

      so all i need to do now is insert into my table 12 records but the problem i have is how can i loop through each date


      the above form entry would be

      12/10/2007 / 09:00
      12/11/2007 / 09:00
      12/12/2007 / 09:00 etc 12 times

      but how can i reference a calendar to get the exact date for each entry and the same if my form Frequency was

        • 1. Re: cycle problem
          dempster Level 1
          If I understand your question, you are selecting a start date and time, a number of cyles, and a frequency. Using the Date Add function, this is fairly simple. You can define the frequency as the appropriate datepart code (d = day, ww = week, m = month) and then loop through the number of cycles:

          <CFLOOP INDEX="cnt" FROM="1" TO="#cycles#">
          <CFSET nextday = DateAdd("#datepart#", 1, startday)>
          <CFSET startday = nextday>
          • 2. Re: cycle problem
            JohnGree Level 1
            ok that sounds good but i already use a loop what i currently have is,
            1. the date and time gets converted into server datetime
            2. loops through the total players
            3. insert a record for each player

            so how would i add your sugestion to my code below?
            • 3. cycle problem
              JohnGree Level 1
              ok that works but only i need the orginal date in the loop ie

              if i select date 10/12/2007 and
              a frequency of ww
              and 2 cycles

              my output is 17/12/2007, 24/12/2007

              so i need the orginal to be outputted aswell?

              <cfset startday = '#form.SMS_Date#'>

              <CFLOOP INDEX="cnt" FROM="1" TO="#form.cycles#">
              <CFSET nextday = DateAdd("#form.Frequency#", 1, startday)>
              <CFSET startday = '#DateFormat(nextday, "dd/mm/yyyy")#'>