Re: string to date conversion

From: "Ramakrishnan Muralidharan" <ramakrishnanm(at)pervasive-postgres(dot)com>
To: "Jerome Alet" <alet(at)librelogiciel(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: string to date conversion
Date: 2005-04-22 09:08:43
Message-ID: 02767D4600E59A4487233B23AEF5C5992A407D@blrmail1.aus.pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)librelogiciel(dot)com]
Sent: Friday, April 22, 2005 2:13 PM
To: pgsql-sql(at)postgresql(dot)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(at)postgresql(dot)org

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jerome Alet 2005-04-22 09:13:41 Re: string to date conversion
Previous Message Jerome Alet 2005-04-22 08:43:01 string to date conversion