Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Time within a number of minutes of a target time
There is probably a better way but this came to mind:
Calculate the time of day in seconds and figure out the high and low
values for the range.
I use the current time minus and plus 5 minutes for the end points
UT1 > l
1 select
2 to_char(sysdate,'SSSSS') as SecFrMidnight 3 ,to_char(sysdate - 5/1440,'SSSSS') as LowRange 4 ,to_char(sysdate + 5/1440,'SSSSS') as HighRange5* from sys.dual
SECFR LOWRA HIGHR
----- ----- -----
39921 39621 40221
UT1 > get t10 -- fld3 is a date column in a simple table 1 select to_char(fld3,'SSSSS') from marktest 2 where to_number(to_char(fld3,'SSSSS')) >= 39425 3* and to_number(to_char(fld3,'SSSSS')) <= 40025 UT1 > /
TO_CH
Where the row returned is a row I just inserted using sysdate to get a row that should meet the test. Another test where I subtracted 3 days from the sysdate before extracting the time also turned up a hit so if you did mean that the date of the month, month, and year do not matter as only the time matters then this will work.
HTH -- Mark D Powell -- Received on Fri Feb 17 2006 - 10:14:49 CST