Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL - ERROR: column "date" cannot be cast to type date

I want to cast a specific column in my PostgreSQL database from character_varying type to type date. phpPgAdmin gives me the following error:

ERROR: column "date" cannot be cast to type date

In Statement: ALTER TABLE "public"."tablename" ALTER COLUMN "date" TYPE date

What should I do ? Thanks

like image 218
Athanasios Emmanouilidis Avatar asked May 11 '11 15:05

Athanasios Emmanouilidis


1 Answers

You might need to convert it to text first:

alter table "foo" alter column "date" type date using ("date"::text::date);
like image 183
Denis de Bernardy Avatar answered Sep 29 '22 12:09

Denis de Bernardy