Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id B227263536D for ; Tue, 10 Mar 2009 09:10:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 25995-01-6 for ; Tue, 10 Mar 2009 09:10:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail20.svc.cra.dublin.eircom.net (mail20.svc.cra.dublin.eircom.net [159.134.118.221]) by mail.postgresql.org (Postfix) with SMTP id 566D6635CB4 for ; Tue, 10 Mar 2009 09:09:22 -0300 (ADT) Received: (qmail 41909 messnum 16316261 invoked from network[86.43.79.16/unknown]); 10 Mar 2009 12:09:19 -0000 Received: from unknown (HELO ?127.0.0.1?) (86.43.79.16) by mail20.svc.cra.dublin.eircom.net (qp 41909) with SMTP; 10 Mar 2009 12:09:19 -0000 Message-ID: <49B65870.60807@iol.ie> Date: Tue, 10 Mar 2009 12:09:20 +0000 From: Raymond O'Donnell Reply-To: rod@iol.ie User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: Venkat Rao Tammineni CC: pgsql-general@postgresql.org, pgsql-admin@postgresql.org Subject: Re: [GENERAL] How to Convert VarChar to Date in PgSQL References: <005901c9a178$d00c3c20$7024b460$@com> In-Reply-To: <005901c9a178$d00c3c20$7024b460$@com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 090309-0, 09/03/2009), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200903/127 X-Sequence-Number: 31627 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 ------------------------------------------------------------------