2 Replies Latest reply: Dec 21, 2012 3:44 PM by Marko Banjanin RSS

    Autogenerate months based on start and end date



      I have products and start and end dates of their marketing campaigns. I am having trouble figuring out how to autogenerate month names that fall within each campaign's start and end date in the script.


      Attached is the working file and the text object next to the table that shows desired result.




        • Re: Autogenerate months based on start and end date
          Gysbert Wassenaar

          Try :



          LOAD * Inline [

          Product,    Campaign,        StartDate,        EndDate

          A,            1,                1/1/2011,        3/1/2011

          A,            2,                3/2/2011,        7/1/2011

          A,            3,                7/2/2011,        12/1/2011

          B,            1,                1/1/2012,        3/1/2012

          B,            2,                3/2/2012,        7/1/2012

          B,            3,                7/2/2012,        12/1/2012




          load *, date(AddMonths(StartDate,IterNo()-1),'MMM-YY') as MonthName

          Resident table While AddMonths(StartDate,IterNo()-1)<EndDate;


          drop table table;



          load Product,Campaign,StartDate,EndDate, Concat(MonthName,', ',num(MonthName) ) as Months

          Resident T2 group by Product,Campaign,StartDate,EndDate;


          drop table T2;