Hi,
I have written the function. Just compile it & run with the proper parameters. Please make appropiate exception handling & format in the function.d_Date format should be appropiate according to ur NLS_DATE_FORMAT settings. U can use also TO_CHAR formatting in the function....
================================================== =========
CREATE OR REPLACE FUNCTION DateExample(d_Date IN DATE,
i_Val IN NUMBER,
v_day IN VARCHAR2) RETURN DATE AS
sSqlQuery VARCHAR2(100);
d_computedDate DATE;
BEGIN
IF i_Val > 0 THEN
sSqlQuery := 'SELECT NEXT_DAY(''' || d_Date || ''',''' || UPPER(v_day) ||
''') + ' || i_val * 7 || ' FROM DUAL';
ELSE
sSqlQuery := 'SELECT NEXT_DAY(''' || d_Date || ''',''' || UPPER(v_day) ||
''') - ' || ABS(i_Val) * 7 || ' FROM DUAL';
END IF;
EXECUTE IMMEDIATE (sSqlQuery)
INTO d_computedDate;
RETURN d_computedDate;
END DateExample;
================================================== =========
Subhendu De
[email protected]
Software Developer
New Delhi, India