I have varchar
data type column and date
data type column.
I have to update varchar
column data into date
column
UPDATE tableName SET dateColumn=to_date(varcharColumn, 'DD MM YYYY')
Assuming you are saving "07 04 2010"
You can find further examples and explanation in the documentation:
http://www.postgresql.org/docs/current/interactive/functions-formatting.html
syntax for typecasting:
alter table table_name alter column_name
type converting_data_type using(column_name::converting_data_type)
converting from varchar to date
alter table table_name
alter column_name type date using(column_name::date)
ALTER TABLE <tablename> ALTER COLUMN <columnname> TYPE DATE
using to_date(<columnname>, 'YYYY-MM-DD');
to_date('05 Dec 2000', 'DD Mon YYYY')