Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Date field by 1 Day??

Status
Not open for further replies.

aljubicic

Programmer
Nov 7, 2002
82
AU
Hi,

How would I write an update to increment the date field for a dataset by one day

the column is a timestamp like '12-Sep-2006 12:34:00'

I just want to increment the date part by a day and leave the time component as is.

eg. update [table_name] set [column_name] = .......

Any examples would help.

Thanks
Anthony
 
SQL> drop table tom;

Table dropped.

SQL> create table tom(x date);

Table created.

SQL> insert into tom(x) values(sysdate);

1 row created.

SQL> select to_char(x,'dd-mon-yyyy hh24:mi:ss') from tom;



TO_CHAR(X,'DD-MON-YY
--------------------
22-sep-2006 09:03:53

SQL> update tom set x = x + 1;

1 row updated.

SQL> select to_char(x,'dd-mon-yyyy hh24:mi:ss') from tom;

TO_CHAR(X,'DD-MON-YY
--------------------
23-sep-2006 09:03:53

 
aljubicic,

assuming the existence of an appropriately named table:-

Code:
UPDATE aljubicic
   SET aljubicic_date = aljubicic_date + 1;
COMMIT;

Basically, add one to the value of a date field, and the time is left along, and the date increments.

It's as straight forward as that.

Regards

Tharg

Grinding away at things Oracular
 
taupirho,

sorry about my response, I unintentionally cross posted.
I obviously neglected to refresh my browser before submitting.

My apologies

Tharg

Grinding away at things Oracular
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top