0 Replies Latest reply on Nov 26, 2009 1:13 PM by Yozef0

    Break Date Range by Week / Month

    Yozef0 Level 1

      I have an ArrayCollection which is made up of Objects in the following form:

       

      AC = { site='abc.com' date="2009-10-01" visits="2000" ...},
           { site='abc.com' date="2009-10-02" visits="2000" }, 
           { site='abc.com' date="2009-10-03" visits="2000" }, 
           { site='abc.com' date="2009-10-04" visits="2000" }, 
           { site='abc.com' date="2009-10-04" visits="2000" }, 
           { site='abc.com' date="2009-10-05" visits="2000" }, 
           { site='abc.com' date="2009-10-06" visits="2000" }, 
           { site='abc.com' date="2009-10-07" visits="2000" }, 
           { site='abc.com' date="2009-10-08" visits="2000" }, 
           { site='xyz.com' date="2009-10-01" visits="2000" }, 
           { site='xyz.com' date="2009-10-02" visits="2000" }, 
           { site='xyz.com' date="2009-10-03" visits="2000" },
           { site='xyz.com' date="2009-10-04" visits="2000" },
                ...
      

       

      I'd like to break up this ArrayCollection into Weeks and Months. As in, group them into an Advanced Datagrid by Group Week.

       

      I imagine I should be adding a key to each object that specifies Week 1, Week 2, etc; by getting the getDay() to being 1 (for Mondays), and the result would be:

       

      AC = { site='abc.com' date="2009-10-01" visits="2000" week="Week1"},
           { site='abc.com' date="2009-10-02" visits="2000" week="Week1"}, 
           { site='abc.com' date="2009-10-03" visits="2000" week="Week1"}, 
           { site='abc.com' date="2009-10-04" visits="2000" week="Week1"}, 
           { site='abc.com' date="2009-10-04" visits="2000" week="Week1"}, 
           { site='abc.com' date="2009-10-05" visits="2000" week="Week1"}, 
           { site='abc.com' date="2009-10-06" visits="2000" week="Week1"}, 
           { site='abc.com' date="2009-10-07" visits="2000" week="Week1"}, 
           { site='abc.com' date="2009-10-08" visits="2000" week="Week2"}, 
           { site='abc.com' date="2009-10-09" visits="2000" week="Week2"},
           { site='abc.com' date="2009-10-10" visits="2000" week="Week2"},
           { site='xyz.com' date="2009-10-01" visits="2000" week="Week1"}, 
           { site='xyz.com' date="2009-10-02" visits="2000" week="Week1"}, 
           { site='xyz.com' date="2009-10-03" visits="2000" week="Week1"},
           { site='xyz.com' date="2009-10-04" visits="2000" week="Week1" },
      
      
      

       

       

      Anybody got any other ideas?