Q
Problem solve Get help with specific problems with your technologies, process and projects.

Calculating time differences

I have two fields in my table which are start_date & end_date, both of which are of type date and store date in the format mm/dd/yyyy hh:mm:ss.

I would like to know how can I calculate time differences between these two dates. If the two dates are same but time is different ...how could I get time difference using an SQL query in Oracle?

The format for dates is just used for displaying and inserting data. It is not actually stored in that format. It is stored in Oracle's DATE format.

To display the difference between two date fields, just subtract the two columns!! It's that simple. But you'll want to display in a format that shows you the entire result. For example, look at the following query:

SELECT TO_CHAR(end_date-start_date,'MM/DD/YY
HH24:MI:SS') AS date_difference
FROM table_name;
Subtracting the two columns gave us the difference. Converting to a format we can understand completed the step.

For More Information


Dig Deeper on Oracle database design and architecture

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close