title: list of weeks with Start and End Day for a given period in Oracle
body: <p>I am working on a report and need to pull data on a weekly basis with monthly breakup for a given period.</p>
  
  <p>Here are my requirements</p>
  
  <p>1) I need weekly data for the given period starting from (1.1.2013) to (6.30.2013) with Monthly break up (Jan, Feb, Mar, etc...) (I kind of got a solution for this..)</p>
  
  <p>I am expecting below output.</p>
  
  <pre><code>Week1 01.01.2013  01.07.2013
  Week2 01.08.2013  01.14.2013
  Week3 01.15.2013  01.21.2013
  Week4 01.22.2013  01.28.2013
  Week5 01.29.2013  01.31.2013 (Week 5 is Partial week)
  Week6 02.01.2013  02.07.2013 (First week of Month 2)
  .....
  </code></pre>
  
  <p>2) This is my Crucial Requirement,
  sometimes I get start date in the mid of the month lets say 01.08.2013  and end date 06.30.2013. In such cases Monthly break would go beyond current month. something like (01.08.2013 to 02.07.2013, 02.08.2013 to 03.07.2013, etc...)<br>
  So My output should be</p>
  
  <pre><code>Week1 01.08.2013  01.14.2013
  Week2 01.15.2013  01.21.2013
  Week3 01.22.2013  01.28.2013
  Week4 01.29.2013  02.04.2013 (Week 4 goes to Feb Month)
  Week5 02.05.2013  02.07.2013 (Month ends on Week 5 )
  Week6 02.08.2013  02.14.2013 (1st week of Month 2)
  Week7 02.15.2013  02.21.2013
  .....
  </code></pre>
  
  <p>I am looking for a SQL query in Oracle. </p>
  
  <p>Any inputs are greatly appreciated.</p>
  
  <p>So far I got below code (I got this from Stackoverflow fourm)</p>
  
  <pre><code>select to_char(gen.d,'YYYY "cW"IW')
           , min(gen.d)
           , max(gen.d)
        from (
               select to_date('01.01.2013','DD.MM.YYYY') + level -1 d
                 from dual
              connect by level &lt;= 180 -- Instead of End date, I am passing no of days.
             ) gen
       group by
             to_char(gen.d,'YYYY "cW"IW')
           , to_char(gen.d,'YYYY MM IW')
  </code></pre>