5 Replies Latest reply: Nov 14, 2013 6:07 AM by Clever Anjos RSS

    Loop through months

    Christophe Brock

      Hi,

       

      I need to put a loop on a LOAD statement with the following requirements:

      • A start & end date are defined as non-changing values
      • The loop needs to update 2 other variables which I need to include into the load statement
        • Variable 1: The 1st day of the month (in yyyy-mm-dd format)
        • Variable 2: The last day of the month (also in yyyy-mm-dd format)
      • The loop needs loop through all months starting with the month of the "startdate" and ending with the month of the "enddate" and generate the first and last day of each month into the variables (as described above)

       

      Example:

       

      Assume:

      Startdate: 2013-01-01

      End date: 2013-11-07

       

      Values I want to generate in the first loop:

      vSDate: 2013-01-01

      vEDate: 2013-01-31

       

      Values I want to generate in the second loop:

      vSDate: 2013-02-01

      vEDate: 2013-02-28

       

      etc etc..., ending with in the last loop:

      vSDate: 2013-11-01

      vEDate: 2013-11-30

       

      I was able to do this crawling through the loop day by day, using the formula below, but I'm unable to do the same to loop through the months:

      for zi = date(vStartDateGA,'YYYY-MM') to date(vEndDateGA,'YYYY-MM')

              Let zDate = Date(zi,'YYYY-MM-DD');

              let eDate = MonthEnd(date(zi,'YYYY-MM-DD'));

      next


      Any help would be greatly appreciated.

       

      Kind regards,

      Christophe