Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: how to get the entries from the last 2 hours?

Re: how to get the entries from the last 2 hours?

From: Stephan Born <stephan.born_at_beusen.de>
Date: Tue, 11 Dec 2001 16:41:16 +0100
Message-ID: <3C16291B.C889DB2A@beusen.de>


Angela wrote:
>
> hi all
>
> does somebody know how i cant get the entries from a database which
> were added in the last 2 hours?? i tried it like this:
> select * from logdata where timestamp > (SYSDATE - TO_DATE('2',
> 'HH24'))
>
> i also tried id without '' but it isn't working at all :((
>
> thanks a lot

Try

select *
from logdata
where timestamp > ( sysdate - 2 / 24 )

When you subtract 1 from a date then it will be decreased by 1 day. When subtracting 1/24 then it is decreasing by 1 hour...you get the idea?

BTW.: TO_DATE('2', 'HH24') produces a date on the 1st day of the current month...

Regards, Stephan Received on Tue Dec 11 2001 - 09:41:16 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US