Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Issue in calculating difference between the timestamp

AshK-OracleSep 27 2022 — edited Sep 27 2022

I am calculating the difference betweehn the two timestamps in my code.
One at the beginning of the code and one in the intermediate step.

I am using the below code snippet to calculate the difference.

l_sumruntimeinsec :=  EXTRACT (DAY FROM (systimestamp - l_begintimestamp))*24*60*60+
                          EXTRACT (HOUR FROM (systimestamp - l_begintimestamp))*60*60+
                          EXTRACT (MINUTE FROM (systimestamp - l_begintimestamp))*60+
                          EXTRACT (SECOND FROM (systimestamp - l_begintimestamp));

First time stamp (l_begintimestamp) : 27-SEP-22 05.56.07.685582 AM
Second time stamp (systimestamp): 27-SEP-22 05.56.52.897170000 AM -07:00

Alot of microseconds is getting added in second timestamp.
The difference should have been around 46 seconds but it is showing 45045.211641.

Is there a way to trim the timestamp?

Comments
Post Details
Added on Sep 27 2022
2 comments
300 views