title: Postgresql. Dates interval issue
body: <p>I'm trying to get difference in days, casting result to decimal:</p>
  
  <pre><code>SELECT
  CAST( TO_DATE('2999-01-01','yyyy-mm-dd') - TO_DATE('2909-01-01','yyyy-mm-dd') AS DECIMAL )
  ;
  </code></pre>
  
  <p>Now if I add 1 month to the 2nd date:</p>
  
  <pre><code>SELECT
  CAST( TO_DATE('2999-01-01','yyyy-mm-dd') - (TO_DATE('2909-01-01','yyyy-mm-dd') + INTERVAL '1 MONTH' * (1) ) AS DECIMAL )
  ;
  </code></pre>
  
  <p>I'm getting an error:
  <strong>ERROR: cannot cast type interval to numeric</strong></p>
  
  <p>OK, I can cast to char to get result:</p>
  
  <pre><code>SELECT
  CAST( TO_CHAR( TO_DATE('2909-02-10','yyyy-mm-dd') - (TO_DATE('2909-01-01','yyyy-mm-dd') + INTERVAL '1 MONTH' * (1) ), 'DD') AS DECIMAL )
  ;
  </code></pre>
  
  <p>But in this case the 1st query modified with TO_CHAR casting stop working:</p>
  
  <pre><code>SELECT
  CAST( TO_CHAR(TO_DATE('2999-01-01','yyyy-mm-dd') - TO_DATE('2909-01-01','yyyy-mm-dd'), 'DD') AS DECIMAL )
  ;
  </code></pre>
  
  <p>I'm getting <strong>ERROR: multiple decimal points.</strong></p>
  
  <p>So, my question is, how can I get days using the same sql statement? For both sql queries.</p>