kooro...@gmail.com wrote:
> On Tuesday, June 18, 2013 1:22:23 AM UTC+10,
artm...@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;
/