title: Running query against quarter or week of the year
body: <p>I have this query that works for 1 quarter. However, what if I want to do the same query but for 2nd, 3rd, and 4th quarter of the calendar year or even WEEKLY?</p>
  
  <p>How can I do the same query without having to manually change the values defining the quarter or week of the year?</p>
  
  <pre><code>SELECT count(1), AVG(resolved_at::TIMESTAMP - created_at::TIMESTAMP) 
  FROM supp_cases 
  WHERE created_at::TIMESTAMP &gt;= '2017-01-01 00:00:00'::TIMESTAMP 
  AND resolved_at::TIMESTAMP &lt;= '2017-03-31 23:59:59'::TIMESTAMP;
  
  Q1 = 2017-01-01 00:00:00 TO 2017-03-31 23:59:59
  Q2 = 2017-04-01 00:00:00 TO 2017-06-30 23:59:59
  Q3 = 2017-07-01 00:00:00 TO 2017-09-30 23:59:59
  Q4 = 2017-10-01 00:00:00 TO 2017-12-31 23:59:59
  </code></pre>