title: Ingres multiplication gives wrong result
body: <p>I have an Ingres table with following columns</p>
  
  <pre><code>from_date ingresdate
  to_date ingresdate
  model_amt money
  </code></pre>
  
  <p>The dates can reflect a period of any number of days, and the model_amt is always a weekly figure. I need to work out the the total model_amt for the period</p>
  
  <p>To do this I need to know how many days are covered by the period, and then divide model_amt by 7, and multiply it by the number of days</p>
  
  <p>however, I am getting incorrect results using the code below</p>
  
  <pre><code>select model_amt, date_part('day',b.to_date - b.from_date), 
  model_amt / 7 * int4( (date_part('day',b.to_date - b.from_date)) )
  from table
  </code></pre>
  
  <p>For example, where model_amt = 88.82 and the period is for 2 weeks, I get the following output</p>
  
  <pre><code>+-------------------------------------------------------+
  ¦model_amt           ¦col2         ¦col3                ¦
  +--------------------+-------------+--------------------¦
  ¦              #88.82¦           14¦             #177.66¦
  +-------------------------------------------------------+
  </code></pre>
  
  <p>But 88.82 / 7 * 14 = 177.64, not 177.66?</p>
  
  <p>Any ideas what is going on? The same issue happens regardless of whether I include the int4 function around the date_part.</p>
  
  <p><strong>* Update 15:28 *</strong></p>
  
  <p>The solution was to add a float8 function around the model_amt</p>
  
  <pre><code>float8(model_amt)/ 7 * interval('days', to_date - from_date)
  </code></pre>
  
  <p>Thanks for the responses.</p>