Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8594

Re: Subtract timestamps, result with fractions of seconds

$
0
0

If you use the format 'SSSSS.FF7' in TO_VARCHAR, you can get the seconds in the day with full precision. So here's a version that I think would work for any two timestamps:

    DAYS_BETWEEN(t1, t2) * 86400.0    + (TO_DECIMAL(TO_VARCHAR(t2, 'SSSSS.FF7'), 15, 7)    - TO_DECIMAL(TO_VARCHAR(t1, 'SSSSS.FF7'), 15, 7))

 

Graham


Viewing all articles
Browse latest Browse all 8594


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>