Should I use CAST? - Mailing list pgsql-general

From Campano, Troy
Subject Should I use CAST?
Date
Msg-id 9534B16F750ED2118CF90008C724C4460C22228B@lmig-msg-20.lmig.com
Whole thread Raw
Responses Re: Should I use CAST?
List pgsql-general

I have two tables that are basically the same.  They have different data types through.  I am trying to load data from one table to another and I get the error:

ERROR:  Attribute 'cert_expiration' is of type 'date' but expression is of type 'varchar'
        You will need to rewrite or cast the expression

So I tried this:

-----------------------------------------------------
INSERT INTO ebs_webserver_t (
install_directory,
server_instance_nme,
docs_directory_nme,
other_info,
port_num,
host_nme,
ip_num,
cert_expiration,
dns_nme,
url_nme,
app_contact_id,
cert_type_id,
domain_id,
node_id, 
environment_id,
sbu_id,
server_type_id
)
SELECT
install_directory,
server_instance_nme,
docs_directory_nme,
other_info,
port_num,
host_nme,
ip_num,
CAST(cert_expiration AS DATE),
dns_nme,
url_nme,
app_contact_nme,
cert_type_id,
domain_id,
node_id,
environment_id,
sbu_id,
server_type_id
FROM ebs_webserver_tmp2;
---------------------------------------------------------

Notice I used CAST in the SELECT.  But I get this error:

ERROR:  Cannot cast type 'varchar' to 'date'


Any ideas what I can do to make a VARCHAR column a date?
All the dates are in this format: 10/23/2002




Thanks!

[:==> Troy Campano <==:]
Database (Request Manager/web/database)
http://intranet:3000/infosys/infra/software/database/dbapp/
http://intranet2/reqman/
Microsoft gave you Windows, UNIX the whole house.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Determining current database programmatically
Next
From: Doug McNaught
Date:
Subject: Re: Determining current database programmatically