Re: For Loop w/time interval
From: <kooroorinya_at_gmail.com>
Date: Fri, 21 Jun 2013 00:22:57 -0700 (PDT)
Message-ID: <e0429886-2202-438c-94d2-d19bc998196f_at_googlegroups.com>
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!
Date: Fri, 21 Jun 2013 00:22:57 -0700 (PDT)
Message-ID: <e0429886-2202-438c-94d2-d19bc998196f_at_googlegroups.com>
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):
SET SERVEROUTPUT ON
DECLARE
BEGIN
FOR xx IN (SELECT (TRUNC(SYSDATE) + 8.5/24)+rownum/24/60 The_time
FROM DUAL connect by level <= ((TRUNC(SYSDATE) + 9/24)-(TRUNC(SYSDATE) + 8.5/24))*60*24) LOOP dbms_output.put_line(to_char(xx.the_time,'HH:MI'));
END LOOP;
END;
/
Received on Fri Jun 21 2013 - 09:22:57 CEST