Re: How to Convert VarChar to Date in PgSQL - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: How to Convert VarChar to Date in PgSQL
Date
Msg-id 49B65870.60807@iol.ie
Whole thread Raw
In response to How to Convert VarChar to Date in PgSQL  ("Venkat Rao Tammineni" <vtammineni@roulacglobal.com>)
List pgsql-general
On 10/03/2009 12:07, Venkat Rao Tammineni wrote:
>   I have one table which has lot of data.In the same table I have one
> varchar filed. I want to convert into Date data type? Is It possible to
> convert varchar to date datatype with out loosing data.Please guide me.I am
> waiting for your great response.

If the varchar is already in the format you need (yyyy-mm-dd) then you
ought to be able just to cast it:

   '2009-03-10'::date

If not, you may need to do some clever things with regular expressions
first to get it into this format, and then cast it.

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

pgsql-general by date:

Previous
From: "Venkat Rao Tammineni"
Date:
Subject: How to Convert VarChar to Date in PgSQL
Next
From: Jaume Sabater
Date:
Subject: Re: [ADMIN] How to Convert VarChar to Date in PgSQL