Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql oracle update date

My table table1 has the column date_txt which includes 2/16/2011 12:00:00 AM - column date_txt is VARCHAR2 (250 Char).

My table table1 also has the column date which is a DATE.

I would like to "update" my field:

The final output should be:

table1:

 date

 2/16/2011

So it takes from table1 date_txt the "date" and updates it to the column date as a date.

Any ideas? I am a bloody beginner.

like image 586
piguy Avatar asked May 31 '26 11:05

piguy


1 Answers

You can use Oracle's to_date function to convert a string to a date:

update table1 set "date" = to_date(date_txt, 'MM/DD/YYYY HH:MI:ss AM')

See it working at SQL Fiddle.

like image 126
Andomar Avatar answered Jun 03 '26 01:06

Andomar