Today I needed a PL/SQL funtion to determine next friday’s date.
Therefore I had to write a strange PL/SQL function. I’m kind of mixed up - am I complicated?
I’m sure there’s a pretty simple Oracle solution out there - hide out!
Hopefully Steven Feuerstein never sees this lines of code. Maybe someon has a better idea than this ….
declare function NextFriday return date is vNextFriday date; vNext date; vFR date; vMO date; begin SELECT trunc(NEXT_DAY(SYSDATE, ‘FRIDAY’ )) into vNextFriday FROM dual; select trunc(sysdate)+7 into vNext from dual; if vNextFriday = vNext then select trunc(sysdate) into vFR from dual; else select trunc(NEXT_DAY(SYSDATE, ‘FRIDAY’)) into vFR from dual; end if; — Monday vMO := vFR-4; — Friday return vFR end NextFriday; begin dbms_output.put_line(’Next Friday: ‘ ||NextFriday); end;
tags:oracle pl/sql





cas said,
2-10-2009 in 21:46:18 at 64.234.168.87I’m looking for code to determine the “2nd Friday of the month” and I found this:
select next_day(sysdate,’FRIDAY’) as NEXT_DAY from dual
however, this prints the next Friday, not the 2nd Friday.
Thought I’d share.