Meridian,
First, if you are working with dates in Oracle, it is
ALWAYS best to use datatype "DATE" to store your information. Oracle has such remarkable date-handling functions, that you sacrifice much by storing dates in VARCHAR2.
If you
must leave "birth_date" as VARCHAR2, then the first thing to confirm is that the VARCHAR2 column maximum is large enough to accommodate the addition of two-character centuries:
Code:
desc <table_name>
Name Null? Type
----------------------- -------- -----------
...
BIRTH_DATE VARCHAR2(8)
...
The above shows that BIRTH_DATE is not large enough to accommodate the addition of century. Therefore, you must execute this change:
Code:
alter table <table_name> modify birth_date varchar2(10);
Table altered.
desc <table_name>
Name Null? Type
----------------------- -------- ------------
...
BIRTH_DATE VARCHAR2(10)
...
To confirm contents of the table:
Code:
select birth_date from <table_name>;
10/06/04
03/08/90
06/17/91
04/07/90
03/04/90
5 rows selected.
To confirm the correctness of your data change before actually making the UPDATEs to each row:
Code:
select to_char(to_date(birth_date,'mm/dd/rr'),'mm/dd/yyyy') birth_date
from <table_name>;
10/06/2004
03/08/1990
06/17/1991
04/07/1990
03/04/1990
5 rows selected.
Then, to actually implement the changes:
Code:
update <table_name>
set birth_date = to_char(to_date(birth_date,'mm/dd/rr'),'mm/dd/yyyy');
5 rows updated.
To confirm the changes before you COMMIT them:
Code:
select birth_date from meridian;
10/06/2004
03/08/1990
06/17/1991
04/07/1990
03/04/1990
5 rows selected.
If all looks good, then:
Let us know if this is what you wanted.
![[santa] [santa] [santa]](/data/assets/smilies/santa.gif)
Mufasa
(aka Dave of Sandy, Utah, USA @ 19:59 (06Oct04) UTC (aka "GMT" and "Zulu"), 12:59 (06Oct04) Mountain Time)