Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL - Time Specific Daily Query
On Dec 7, 3:59 pm, "CRS_UK" <crs..._at_hotmail.com> wrote:
> Hello,
>
> I need to write a query that is time specific. This query will be run
> daily and needs to pick up all orders that have an update date between
> 2:00 AM and 3:00 AM. If it were just for one day, I would know how to
> write the query. But since it needs to run everyday, I'm not sure what
> to do.
>
> Example:
> Col 1 - Order_ID
> Col 2 - Insert_Date
> Col 3 - Update_Date
>
> SELECT Order_id WHERE update_date BETWEEN (2 AM and 3AM)
>
> The (2AM and 3AM) is the part that I am having trouble with. If it
> were one specific, I would use TO_DATE('2006-12-06
> 02:00:00','YYYY-MM-DD HH24:MI:SS'). But since it is everyday, I'm
> stuck.
>
> Thanks for your help!
>
> CRS
select ... where update_date between trunc(sysdate)+(14/24) and
trunc(sysdate)+((15/24) - (1/3600))
-- Sybrand Bakker Senior Oracle DBAReceived on Thu Dec 07 2006 - 09:39:49 CST