Is there any function in Oracle for add day or add week. I want to write a function that will add day or week. Your help will be appreciated.
C.K.
Apps DBA 11i
Printable View
Is there any function in Oracle for add day or add week. I want to write a function that will add day or week. Your help will be appreciated.
C.K.
Apps DBA 11i
Is this what you mean?
RegardsCode:SQL> select sysdate from dual;
SYSDATE
---------
13-JAN-03
SQL> select sysdate+1 from dual;
SYSDATE+1
---------
14-JAN-03
SQL> select sysdate+7 from dual;
SYSDATE+7
---------
20-JAN-03
Or....
If you want a simple function do return a new date when specifing 'D' for day 'W' for week you could try the following
This would give the following output:Code:CREATE OR REPLACE FUNCTION date_advance
(curr_date IN date, adv_flag in varchar)
RETURN date
IS
BEGIN
IF adv_flag = 'D' THEN
RETURN curr_date+1;
ELSIF adv_flag ='W' THEN
RETURN curr_date+7;
ELSE
RETURN curr_date;
END IF;
END date_advance;
RegardsCode:SQL> select date_advance(sysdate,'D') from dual;
DATE_ADVA
---------
14-JAN-03
JIm,
I added the following lines to my function and it worked.
SQL> select sysdate + 1 as ADD_DAY from dual
2 /
ADD_DAY
---------
14-JAN-03
SQL> select sysdate + 7 as ADD_WEEK from dual
2 /
ADD_WEEK
---------
20-JAN-03
Thanks.