Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Getting time difference between two columns in seconds?
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
![]() |
![]() |