title: Data Summarization in Apache Pig/Apache Hive For Given Date Range
body: <p>I have a requirement where-in i need to do data summarization on the date range provided as input. To be more specific: If my data looks like:</p>
  
  <pre><code>Input:
  Id|amount|date
  1 |10    |2016-01-01
  2 |20    |2016-01-02
  3 |20    |2016-01-03
  4 |20    |2016-09-25
  5 |20    |2016-09-26
  6 |20    |2016-09-28
  </code></pre>
  
  <p>And If I want the summarization for the month of September, then
  I need to calculate count of records on 4 ranges which are:</p>
  
  <ol>
  <li>Current Date, which is each day in September.</li>
  <li>Week Start Date(Sunday of the week as per the current date) to Current Date, Ex. if Current Date  is 2016-09-28 then week start date would be 2016-09-25
  and record counts between 2016-09-25 to 2016-09-28.</li>
  <li>Month Start Date to Current Date, which is from 2016-09-01 to Current Date.</li>
  <li>Year Start Date to Current Date,which is record count from 2016-01-01 to Current Date.</li>
  </ol>
  
  <p>So My output should have one record with 4 Columns for each day of the month(in this case, Month is September), Something like</p>
  
  <pre><code>Output:
  
   Current_Date|Current_date_count|Week_To_Date_Count|Month_to_date_Count|Year_to_date_count
  
   2016-09-25  |1                 |1                 |1                  |4
   2016-09-26  |1                 |2                 |3                  |5
   2016-09-28  |1                 |3                 |3                  |6
  </code></pre>
  
  <p><strong>Important:</strong> i can pass only 2 variables, which is range start date and range end date. Rest calculation need to be dynamic.</p>
  
  <p>Thanks in advance</p>