Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Getting time difference between two columns in seconds?

Getting time difference between two columns in seconds?

From: Andre-John Mas <andrejohn.mas_at_gmail.com>
Date: Tue, 24 Jul 2007 08:08:14 -0700
Message-ID: <1185289694.370678.306220@19g2000hsx.googlegroups.com>


Hi,

I am wanting to get the date range between two columns in my database in seconds. I have a column startTime and a column endTime and I want to find out how many seconds has elapsed between the two. Originally I had the following as part of my select statement:

SYSTEM.CALCTIMEDIFF (rc.starttime, rc.endtime) AS duration

This returns a value in the form 'DD HH:MM:ss'. I changed the code to be:

round((rc.endtime - rc.starttime)*24*60*60) AS duration

This works in most cases but is failing in some.

1st method: 00 00:32:45
2nd method: 1966
result: 1 second off

1st method: 00 00:32:41
2nd method: 1961
result: ok

1st method: 00 00:09:59
2nd method: 32999
result: very wrong

Is there a better approach to getting the time difference between two columns and having the results in seconds?

Andre Received on Tue Jul 24 2007 - 10:08:14 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US