Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duration between 2 dates

Status
Not open for further replies.

nread

Technical User
Joined
Oct 31, 2001
Messages
58
Location
GB
Hi

could someone help me with trying to determine the duration in seconds between 2 dates...?

This is what i'm trying to do :

select
START,
RELEASE,
(TO_DATE(
SUBSTR(RELEASE, 1, length(RELEASE) - 4), 'YYYY-MM-DD HH24:MI:SS'))-
(TO_DATE(
SUBSTR(START, 1, length(START) - 4), 'YYYY-MM-DD HH24:MI:SS')) As Duration
from table 1

Thanks everyone...

 
Assuming start and release are already dates, I would take the difference between them (giving me the duration in days), and multiply the results by 86400 (24*60*60) to get seconds.

It would look something like:
Code:
SELECT (release - start) * 86400 "Seconds"
FROM table_1;
 
Since it appears that your columns are NOT date datatypes, I would use something like the following:
Code:
SELECT (to_date(releace,'YYYY-MM-DD HH24:MI:SS') - to_date(start,'YYYY-MM-DD HH24:MI:SS')) * 86400 "Seconds" 
FROM table1;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top