Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Difference between Timestamp - response (4) by dlabar

$
0
0

From another thread and some playing around, I found that this works:
 

SELECT
CURRENT_TIMESTAMP AS t2,
(t2 - INTERVAL '9999' DAY - INTERVAL '30' DAY + INTERVAL '1.3' SECOND) AS t1,
CAST((CAST(t2 AS DATE) - DATE '1970-01-01') * 86400
+ (EXTRACT(HOUR FROM t2) * 3600)
+ (EXTRACT(MINUTE FROM t2) * 60) AS DECIMAL(18))
+ (EXTRACT(SECOND FROM t2)) AS t2_s,
CAST((CAST(t1 AS DATE) - DATE '1970-01-01') * 86400
+ (EXTRACT(HOUR FROM t1) * 3600)
+ (EXTRACT(MINUTE FROM t1) * 60) AS DECIMAL(18))
+ (EXTRACT(SECOND FROM t1)) AS t1_s,
t2_s - t1_s AS delta_s


Viewing all articles
Browse latest Browse all 27759

Trending Articles



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