Oracle query for time difference in seconds

Viewed 35303

I am looking for a query to find the gap between two time fields.

Table A and table B in both COL3 contain time value. 8:13:54. COL3 Is a Char field.

Table B also having same fields. I Want to query on the following conditions.

A.COL1 = B.COL1 and 
A.COL2 = B.COL2 and 
(COL3 in a should equal to + / - 120 secs of COL B).

I tried to use TO_DATE, but its not working out. How can i achieve this?

This works for me. Thanks.

SELECT A., B. FROM A, B WHERE A.COL1 = B.COL1 AND A.COL2 = B.COL2 AND ( TO_DATE(B.COL3,'hh:mi:ss') = (TO_DATE(B.COL3,'hh:mi:ss') + (120/(24*60*60))) OR TO_DATE(B.COL3,'hh:mi:ss') = (TO_DATE(B.COL3,'hh:mi:ss') - (120/(24*60*60))) )

1 Answers
Related