How I can substract one timestamp from another in Oracle

How can I subtract one timestamp from another in Oracle?

for example I have:

timestamp_1 = 2021-06-25 08:18:17,207141  
timestamp_2 = 2021-06-24 17:41:06,787111  

how I can take a different between?

I need a diff in seconds

Upvotes: 2

Views: 77

Answers (1)

EJ Egyed
EJ Egyed

Reputation: 6084

You can simply subtract the two values from each other

SELECT   TO_TIMESTAMP ('2021-06-25 08:18:17,207141', 'YYYY-MM-DD HH24:MI:SS,FF')
       - TO_TIMESTAMP ('2021-06-24 17:41:06,787111', 'YYYY-MM-DD HH24:MI:SS,FF')
  FROM DUAL;


+00 14:37:10.420030

Upvotes: 1

Related Questions