Q

Finding precise difference in time and date values

What is the best function/way to find the difference in time and date value in the range of 1/1000th precision?

What is the best function/way to find the difference in time and date value in the range of 1/1000th precision?

e.g., Time: 25.456 (sec) - 22.349 (sec)
Time: 25-Sep-06 15:44:22.453 - 20-Sep-06 17:22:45.276

The only Oracle datatype that will handle fractional seconds is the TIMESTAMP datatype. Once you have two values stored as timestamps, the easisest way to find the difference is to just subtract the two values. For instance:
SELECT TO_TIMESTAMP('MM/DD/YY HH24:MI:SS.SSS','09/25/06 15:22:22.453') - 
              TO_TIMESTAMP('MM/DD/YY HH24:MI:SS.SSS','09/20/06 17:22:45.276') 
FROM dual;
This was last published in October 2006

Dig Deeper on Oracle database design and architecture

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close