Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> How to select within a time range
I am trying to match a phone bill sent to our company with
the records that we keep. If our clock and the phone company's
clock were perfectly synchronized, something like the following
would suffice:
select name from calls where day = '12-feb-03' and call_time = '09:43:10';
but in this imperfect world, I will need to have some range like:
select name from calls where
day = '12-feb-03' and call_time >= '09:42:55' and call_time <= '09:43:25';
Since the above values are going to be variables, I need some sort of time function to verify the inequality:
$time - 10 seconds <= $fixed_time <= $time + 10 seconds
I would like to make sure that the above works across days.
In Unix, I would convert all the dates to seconds, before checking to see if a particular date falls inside the range, but how should I do this in SQL? Should I change everything to seconds?
TIA, -Ramon F. Herrera Received on Sat Jun 07 2003 - 00:43:09 CDT