Re: For Loop w/time interval

From: Gerard H. Pille <ghp_at_skynet.be>
Date: Fri, 21 Jun 2013 18:05:30 +0200
Message-ID: <51c479ca$0$3114$ba620e4c_at_news.skynet.be>



kooroorinya_at_gmail.com wrote:
> On Tuesday, June 18, 2013 1:22:23 AM UTC+10, artm..._at_gmail.com wrote:
>> Hi,
>>
>>
>>
>> I need to write a FOR LOOP which uses minutes as the interval, from a start time to and end time.
>>
>>
>>
>> So, maybe something like this (pseudo english):
>>
>>
>>
>> For x IN (8:30 - 3:00 INTERVAL 1 minute) LOOP
>>
>> .
>>
>> .
>>
>> .
>>
>> END LOOP
>>
>>
>>
>> Where X will be the HH:MI that the loop is performing on. I'll need access to that HH:MI to compare it against other things.
>>
>>
>>
>> But, how to create the loop which will use the hour / minute?
>>
>>
>>
>> Thanks!
>
> Something like this (with refinement):

Something like this (without troubling the database)?

declare

   v_start date := trunc(sysdate) + 3/24;
   v_end   date := trunc(sysdate) + 8.5/24;
   v_hhmm  varchar2(5);

begin

   while v_start <= v_end loop

     v_hhmm := to_char(v_start,'HH24:MI');
     dbms_output.put_line(v_hhmm);
     v_start := v_start + 1/(24*60);

   end loop;
end;
/ Received on Fri Jun 21 2013 - 18:05:30 CEST

Original text of this message