I am trying to create a table with the third Friday of the month for each month in the past year. I know how to do this for one month at a time but am having trouble in returning a range of dates instead. I have tried to do this using a for loop:
create table fridays as
begin
for i in 1..365
loop
select next_day(trunc(sysdate - i,'MM')+13,'FRIDAY') third_friday
from dual
end loop;
Do I need to have an array to put these values into or am I going wrong somewhere else?
Do you mean something like this?
Here is a sqlfiddle demo
UPDATE In reference to @APC’s comment:
If you don’t want to rely on NLS_TERRITORY then you can do something like this: