 <p>In ANSI standard SQL, you can do:</p> <pre><code>select (extract(year from col)*100000 + extract(month from col)*100 + extract(day from col)*1 + (extract(hour from col)*3600 + extract(minute from col)*60 + extract(second from col)) / (24.0*60*60) ) </code></pre>