title: Cast integer to numeric, then take log
body: <p>I have a table in redshift with 2 timestamps, stored as integers.  I want to date the difference of the 2 timestamps, convert from seconds to days, and then take the log of the result.</p>
  
  <p>e.g.:</p>
  
  <pre><code>select cast(t1 - t2 as numeric)/86400 as diff from mytable limit 5
  </code></pre>
  
  <p>Which yields:</p>
  
  <pre><code>      diff
  1 0.000011
  2 1.379166
  3 1.365104
  4 1.357002
  5 17.356759
  </code></pre>
  
  <p>However, when I add the log function, the statements fails:</p>
  
  <pre><code>select log(cast(t1 - t2 as numeric)/86400) as diff from mytable limit 5
  </code></pre>
  
  <p>yields:</p>
  
  <pre><code>Function "log(numeric,numeric)" not supported.
  </code></pre>
  
  <p>This is surprising, because the log function operates just fine on numeric and integer columns in the same table.  Is there some magic I need to do after the cast function, before taking the log?  Or is there a different data type I should be casting to?</p>
  
  <p>Oddly enough, this statement works just fine:</p>
  
  <pre><code>select log(cast(1410551376-1310551376 as numeric)/86400) as diff
  </code></pre>
  
  <p>yielding:</p>
  
  <pre><code>      diff
  1 3.063486
  </code></pre>
  
  <p>/edit: I also get the same error if I remove the explicit cast:</p>
  
  <pre><code>select log((t1 - t2)/86400.0) as diff from mytable limit 5
  </code></pre>