Re: [Q] DATE - 1/2 hour ????
Date: 1996/10/08
Message-ID: <325A7603.97E_at_ix.netcom.com>#1/1
Keyoor wrote:
>
> Date : 08/10/1996
> Ref : news4.txt
>
> Hi folks !
>
> I want to subtract 1/2 an hour from any given date and find the records
> between these 2 dates.
>
> Can anybody give me the answer !
>
> Please send the answers to my e-mail also.
>
> Thanks in advance.
>
> Keyoor.
>
> --
> ---------------------------------------------------
> How HIGH You go depends on How DEEP Your Roots are.
> ---------------------------------------------------
> Keyoor Anant Brahme
declare
l_seconds_per_minute NUMBER := 60; l_first_date DATE := SYSDATE; l_second_date DATE := l_first_date - to_date (to_char (l_seconds_per_minute * 30), 'SSSSS');begin
select stuff
from real_stuff
where real_stuff.date >= l_second_date
and real_stuff.date <= l_first_date;
end;
Though there are many other ways to do it, this is probably the easiest
to understand.
The to_date function is using 'SSSSS' to convert to number of seconds
since midnight.
You really don't care about that. All you really want to do is get 30
minutes in
a date variable so you can use date arithmetic, which this will
accomplish. I saw
another post on here using 1/48 of a day. That will work, but could get
very ugly
when we start talking odd increments in seconds and minutes. You could
certainly
calculate what part of a day anything is, but mine will convert to any
seconds/
minutes you choose.
Loyal Received on Tue Oct 08 1996 - 00:00:00 CEST