DECLARE
l_date DATE := '&P_ENTER_ANY_DATE';
l_first_sunday DATE;
l_last_sunday DATE;
BEGIN
--Find 1st Sunday
l_first_sunday := NEXT_DAY (TRUNC (l_date, 'YYYY') - 1, 'SUN');
--Find last Sunday
l_last_sunday := NEXT_DAY (ADD_MONTHS (TRUNC (l_date, 'YYYY') - 1, 12), 'SUN') - 7;
WHILE l_first_sunday <= l_last_sunday
LOOP
DBMS_OUTPUT.PUT_LINE ( l_first_sunday);
l_first_sunday := l_first_sunday + 7;
END LOOP;
END;
Thanks for sharing.
ReplyDelete