A little bit different approach which doesn't require a PL/SQL block.
You can use a recursive query to build a set of dates. In that query check the day of the week and based on that, include it in calculation or not. In other words only working days are counted.
Consider the following statement:
WITH dates (SingleDate, DayOfWeek, Include, DayCumulator) AS (
SELECT TRUNC(SYSDATE - level + 1) AS SingleDate,
TO_NUMBER(TO_CHAR(SYSDATE - level + 1, 'D')) AS DayOfWeek,
CASE TO_NUMBER(TO_CHAR(SYSDATE - level + 1, 'D'))
WHEN 1 THEN 0
WHEN 7 THEN 0
ELSE 1
END AS Include,
SUM(CASE TO_NUMBER(TO_CHAR(SYSDATE - level + 1, 'D'))
WHEN 1 THEN 0
WHEN 7 THEN 0
ELSE 1
END ) OVER (ORDER BY TRUNC(SYSDATE - level + 1) DESC) AS DayCumulator
FROM dual
CONNECT BY Level <= 1000
)
SELECT SingleDate,
DayOfWeek,
Include,
DayCumulator
FROM dates
It would return a result set like
SingleDate DayOfWeek Include DayCumulator
---------- --------- ------- ------------
15.08.2015 6 1 1
14.08.2015 5 1 2
13.08.2015 4 1 3
12.08.2015 3 1 4
11.08.2015 2 1 5
10.08.2015 1 0 5
09.08.2015 7 0 5
08.08.2015 6 1 6
07.08.2015 5 1 7
06.08.2015 4 1 8
05.08.2015 3 1 9
04.08.2015 2 1 10
03.08.2015 1 0 10
02.08.2015 7 0 10
01.08.2015 6 1 11
...
So now to get the date with certain amount of days in between, just add a WHERE condition, like
WITH dates (SingleDate, DayOfWeek, Include, DayCumulator) AS (
SELECT TRUNC(SYSDATE - level + 1) AS SingleDate,
TO_NUMBER(TO_CHAR(SYSDATE - level + 1, 'D')) AS DayOfWeek,
CASE TO_NUMBER(TO_CHAR(SYSDATE - level + 1, 'D'))
WHEN 1 THEN 0
WHEN 7 THEN 0
ELSE 1
END AS Include,
SUM(CASE TO_NUMBER(TO_CHAR(SYSDATE - level + 1, 'D'))
WHEN 1 THEN 0
WHEN 7 THEN 0
ELSE 1
END ) OVER (ORDER BY TRUNC(SYSDATE - level + 1) DESC) AS DayCumulator
FROM dual
CONNECT BY Level <= 1000
)
SELECT SingleDate,
DayOfWeek,
Include,
DayCumulator
FROM dates
WHERE DayCumulator = 7;
The result would be
SingleDate DayOfWeek Include DayCumulator
---------- --------- ------- ------------
07.08.2015 5 1 7
Note that NLS settings may affect which number is returned for each weekday.