Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Auto generating date sequence

577737May 15 2007 — edited May 15 2007
Hello to the community

I have the task to auto generate date sequences, such that I have to select the friday of each week. The friday date generated cannot exceed the friday of the current week (given any starting point). On another forum I found a code, but the one shown here is modified. Since I am completely new to functions in Apex, here is my code


CREATE OR REPLACE FNSEQDATES( lowlimit in DATE, highlimit in DATE)
RETURN DATE
IS
value

BEGIN

IF lowlimit > highlimit
set temp = lowlimit
lowlimit = highlimit
highlimit = temp;
END IF;

INSERT INTO value VALUES (lowlimit)

WHILE ROWCOUNT > 0
INSERT INTO value SELECT DATEADD(dd, t.items, d.value)
FROM value d CROSS JOIN (SELECT COUNT(*) items FROM value) t
WHERE DATEADD(dd, t.items, d.value) <= highlimit
RETURN value

END;

and then maybe call the following statement, to generate dates

SELECT value FROM FNSEQDATES('1/1/2006', '3/31/2006' ) WHERE DATEPART(dw, value) = 6 and value <= '5/31/2007'

Clearly, my function is incorrect (psst.. it doesnt work). I was wondering if someone could assist me in solving this little tiny issue. Cheers.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2007
Added on May 15 2007
5 comments
12,704 views