|
CREATE OR REPLACE PROCEDURE GETREQUIREDDATE (
inputDate int, basedate date, res OUT date)
AS
add_day int;
minus_day int;
diff_day int;
days int;
BEGIN
days := to_NCHAR( to_date(baseDate), 'D');
add_day := mod((inputDate - days + 7),7);
minus_day := mod((inputDate - days - 7), 7);
diff_day := (1- floor(abs(add_day)/3.5)) * add_day + (1-floor(abs(minus_day)/3.5)) * minus_day;
res := basedate + diff_day;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END GETREQUIREDDATE;
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.