pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ramakrishnan Muralidharan <ramakrishnanm@pervasive-postgres.com>
To: Jerome Alet <alet@librelogiciel.com>
To: pgsql-sql@postgresql.org
Subject: Re: string to date conversion
Date: Fri, 22 Apr 2005 14:38:43 +0530
Message-ID: <02767D4600E59A4487233B23AEF5C5992A407D@blrmail1.aus.pervasive.com> (raw)

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



view thread (6+ messages)  latest in thread

Message-ID: <02767D4600E59A4487233B23AEF5C5992A407D@blrmail1.aus.pervasive.com>
Permalink:  ../02767D4600E59A4487233B23AEF5C5992A407D@blrmail1.aus.pervasive.com/
Also on:    postgresql.org/message-id/02767D4600E59A4487233B23AEF5C5992A407D@blrmail1.aus.pervasive.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: ramakrishnanm@pervasive-postgres.com, alet@librelogiciel.com
  Subject: Re: string to date conversion
  In-Reply-To: <02767D4600E59A4487233B23AEF5C5992A407D@blrmail1.aus.pervasive.com>
  References: <02767D4600E59A4487233B23AEF5C5992A407D@blrmail1.aus.pervasive.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox