SELECT add_months( date_column, -12 * 100 )
FROM table
To update the table, assuming there are no rows that are supposed to be greater than 2090...
UPDATE advdb.custtest_barb
SET crdate = add_months( crdate, -12 * 100 )
WHERE crdate > to_date( '01-01-2090 ', 'DD-MM-YYYY ' )
Justin Cave
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
-- --Original Message-- --
From: oracle-l-bounce@(protected) [mailto:oracle-l-bounce@(protected)] On Behalf Of Barbara Baker
Sent: Tuesday, March 23, 2004 1:01 PM
To: oracle-l@(protected)
Subject: update year in date column
OK, I 'm just going to bite the bullet and claim total ignorance here and see if someone takes pity on me :( (sad face a nice touch, eh?)
Someone has accidently updated 378 records in the customer table. The date changed from 1999 to 2099.
I need to change just the year back to 1999 for these records. (I 'd like to keep the time stamp, if possible. The month and day are correct.) I looked on metalink, google, and asktom. Some nice examples, but not what I really need.
Thought I 'd be clever and subtract 1000 from the date.
This works, but I don 't know how to get it formatted back into a date.
I 'd prefer just sqlplus, but will use pl/sql if necessary.
Here 's what I 've done so far:
(solaris 9 oracle 9.2.0.4)