Oracle - Query Based On Time Of Day

Soldato
Joined
8 Oct 2005
Posts
4,184
Location
Midlands, UK
Hi,

Can someone point me (not give me the answer) in the right direction in how get an Oracle query to only function during certain times of the day. I'm sure 'sysdate' will come into it somewhere, but other than that I can't find anything :(

Thanks
 
What exactly do you mean by 'only function during certain times of the day'?

You can do TO_CHAR(sysdate,'HH24:MI:SS') to return the current time of day, but not sure exactly what you mean?
 
Apparently there is some method to make a query on return a result during a certain time of the day. For instance i have a simple query (select * from sometable) and only want it to display results if the time of the day is say from 13:00 - 20:00 hours. If the query is run outside those hours, no rows are returned.


EDIT: actually, found this does the job, although it does seem a bit crude (there must be a better way?):

Code:
 [FONT=Tahoma]SELECT mehfield[/FONT]
 [FONT=Tahoma]FROM  sometable[/FONT]
 [FONT=Tahoma]WHERE TO_NUMBER(TO_CHAR(SYSDATE,’HH24.MM’,’99.99)[/FONT]
 [FONT=Tahoma]BETWEEN 13.0 AND 20.0;[/FONT]
 
Last edited:
Back
Top Bottom