title: pass variable into postgresql's date extract() function?
body: <p>I can't work out how to pass a variable into the postgresql extract function like:</p>
  
  <pre><code>select 'day' as i;
  extract(i from a_date)
  </code></pre>
  
  <p>that gives me </p>
  
  <blockquote>
    <p>ERROR:  timestamp with time zone units
    "i" not recognized</p>
  </blockquote>
  
  <p>If I can pass in a string, extract('day' from a_date), why not a variable ?</p>