Home » SQL & PL/SQL » SQL & PL/SQL » Add day to a date
Add day to a date [message #32737] Fri, 03 September 2004 04:44 Go to next message
Milly
Messages: 72
Registered: March 2004
Member
Hi!!

I have to add a xx number of day to a date...

I see that there's a function add_month...but not one for the day...

any idea?

thanks!!
Re: Add day to a date [message #32738 is a reply to message #32737] Fri, 03 September 2004 05:02 Go to previous messageGo to next message
x
Messages: 5
Registered: December 2000
Junior Member
to get the date 10 days after..
select sysdate+10 from dual

similarly to get say X days after from current date...
select sysdate+ X from dual
Re: Add day to a date [message #32740 is a reply to message #32738] Fri, 03 September 2004 05:40 Go to previous messageGo to next message
Milly
Messages: 72
Registered: March 2004
Member
Thanks!
Re: Add day to a date [message #32743 is a reply to message #32738] Fri, 03 September 2004 08:32 Go to previous messageGo to next message
Mark
Messages: 284
Registered: July 1998
Senior Member
Try this function....
FUNCTION add_days
 (input_date IN DATE,
  input_days IN integer)
  RETURN DATE IS
  DAYS_ADDED DATE;
BEGIN
  DAYS_ADDED :=(input_date + input_days);
  RETURN DAYS_ADDED;
END;

Then use it in a select...
SELECT shipment_id, date_expected,to_char(add_days(date_expected,30),'mm/dd/yyyy') "30 days"....
Re: Add day to a date [message #32764 is a reply to message #32743] Sun, 05 September 2004 11:59 Go to previous message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
> FUNCTION add_days
> ( input_date IN DATE,
> input_days IN INTEGER )
> RETURN DATE


There is an (admittedly small) context-switching overhead when calling PL/SQL functions in SQL, so a function like this is generally more trouble than it's worth IMHO. I would personally rather add n days to a date than call a function passing the date and the number of days to add. Also having input_days as an integer could be restrictive.
Previous Topic: FIRST_ROWS & PRIMARY KEYS on PUblic Synonyms
Next Topic: help me with this 2 simple assignment problem please.
Goto Forum:
  


Current Time: Mon Apr 28 11:03:51 CDT 2025