tags:

views:

556

answers:

2

I need to all of timestamps in a column the same amount. I want to write an sql statement like:

update sometable set timecol = timecol + <4 months>;

+1  A: 
update sometable set timecol = add_months(timecol,4);

See documentation

Tony Andrews
+1  A: 
update sometable set timecol = timecol + interval '4' month;

Strangely enough, I can't find this in the Oracle documentation anywhere, but it works on my Oracle XE installation. It's fairly close to the way PostgreSQL does it, and I believe it's part of one of the SQL standards.

Paul Tomblin
Yes, using INTERVAL is standard SQL. BTW, I wonder why you put quotes around '4'?
Bill Karwin
Here you go: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements003.htm#SQLRF00221 Quotes are part of the documented dyntax in Oracle, btw.
David Aldridge