Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL Question: How to do an UPDATE to partially change a value?
In article <88ekph$giq$1_at_nnrp1.deja.com>,
robert.bowen_at_mubimedia.com wrote:
> Hello all. I have a question - I have a date column with screwed up
> data. Instead of '1999' in some rows I have '2099'. My own latent Y2K
> bug. Anyway ... what's the easiest way to change these rows, just to
> get rid of the '20' and replace it with '19' ?
>
> I tried doing it using wildcards and old.date_col but I can't get it
to
> work ...
>
> Anyone got a quick fix? I need a hit!
>
> Thanks.
> syg
>
OK, the difference is 100 years (or 120 months)
select * from your_table
where TO_CHAR(your_column, 'YYYY') like '20%';
update your_table
set your_column = add_months(your_column, -1200)
where TO_CHAR(your_column, 'YYYY') like '20%';
then
commit
Hope this helps.
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed Feb 16 2000 - 00:00:00 CST
![]() |
![]() |