Re: [GENERAL] How to Convert VarChar to Date in PgSQL

2009-03-10 Thread Pavel Stehule
hello

2009/3/10 Venkat Rao Tammineni :
> Dear All,
>
>
>
>
>
>   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.
>
>
>

use function to_date, please

 http://www.postgresql.org/docs/8.3/static/functions-formatting.html

postgres=# select to_date('2009-07-17', '-MM-DD');
 to_date
--
2009-07-17
(1 row)

regards
Pavel Stehule

>
>
>
>
> ?Thanx & Regards
>
>  Venkat Rao Tammineni
>
> GIS Developer
>
>

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] How to Convert VarChar to Date in PgSQL

2009-03-10 Thread A. Kretschmer
In response to Venkat Rao Tammineni :
> Dear All,
> 
>  
> 
>  
> 
>   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.

Sure, if you have valid varchar-data.

to_date('2009-03-11'::text, '-mm-dd');


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] How to Convert VarChar to Date in PgSQL

2009-03-10 Thread Raymond O'Donnell
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 (-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
r...@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
--

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] How to Convert VarChar to Date in PgSQL

2009-03-10 Thread Venkat Rao Tammineni
Dear All,

 

 

  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.

 

 

 

?Thanx & Regards

 Venkat Rao Tammineni

GIS Developer