title: Postgresql get first and last day of all iso week in a given year
body: <pre><code>select week_num, week_start, week_end,to_char(week_start,'dd Dy Mon yyyy'), to_char(week_end,'dd Dy Mon yyyy') from(
  WITH RECURSIVE t(n) AS (
      select (date_trunc('week',(date_trunc('week',(2016 || '-01-04')::date)::date - interval '1 day')::date))::date
    UNION ALL
      SELECT (n - interval '1 week')::date  FROM t WHERE  extract(WEEK from n ) &gt; 1
  )
  SELECT n as week_start, (n + interval '6 days')::date as week_end, extract(WEEK from n ) as week_num  
  FROM t 
  ) as weeks order by week_num
  </code></pre>
  
  <p>i wrote this postgresl script to get the first and last day of all iso week in a given year. It is working perfectly, i just need to know if it can be improved</p>