title: Extracting the number of days from a calculated interval
body: <p>I am trying to get a query like the following one to work:</p>
  
  <pre><code>SELECT EXTRACT(DAY FROM INTERVAL to_date - from_date) FROM histories;
  </code></pre>
  
  <p>In the referenced table, to_date and from_date are of type timestamp without time zone. A regular query like </p>
  
  <pre><code>SELECT to_date - from_date FROM histories;
  </code></pre>
  
  <p>Gives me interval results such as '65 days 04:58:09.99'. But using this expression inside the first query gives me an error: invalid input syntax for type interval. I've tried various quotations and even nesting the query without luck. Can this be done?</p>