Re: string to date conversion - Mailing list pgsql-sql

From Ramakrishnan Muralidharan
Subject Re: string to date conversion
Date
Msg-id 02767D4600E59A4487233B23AEF5C5992A407D@blrmail1.aus.pervasive.com
Whole thread Raw
In response to string to date conversion  (Jerome Alet <alet@librelogiciel.com>)
List pgsql-sql
Hi,
 I have tried the same in PostgreSQL 8.0.1 and it is working fine. I have used following example for testing
 create table test1 (   date varchar(10) )
 insert into test1 values('2005/04/22')
 select date::timestamp from test1

Regards,
R.Muralidharan


-----Original Message-----
From: Jerome Alet [mailto:alet@librelogiciel.com]
Sent: Friday, April 22, 2005 2:13 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] string to date conversion


Hi,

I'm working on an existing Pg database which, please don't ask why,
stores dates as varchar attributes in the form 'YYYY/MM/DD'

I'm not allowed to modify the tables to use 'timestamp' instead,
so I'd like to convert on the fly when retrieving datas with
select.

When I do :
       select mydatefield::timestamp from mytable;
There's an error saying that converting from varchar to date is
not possible

How can I do this ?

Thanks in advance

Jerome Alet

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


pgsql-sql by date:

Previous
From: Kai Hessing
Date:
Subject: Re: can a function return a virtual table?
Next
From: "Bill Lawrence"
Date:
Subject: Re: Getting the output of a function used in a where clause