Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 5708A635167; Tue, 10 Mar 2009 09:16:41 -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 28631-01-6; Tue, 10 Mar 2009 09:16:31 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f170.google.com (mail-bw0-f170.google.com [209.85.218.170]) by mail.postgresql.org (Postfix) with ESMTP id 2DF20634F33; Tue, 10 Mar 2009 09:16:37 -0300 (ADT) Received: by bwz18 with SMTP id 18so2242609bwz.19 for ; Tue, 10 Mar 2009 05:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=FV25LLIeXADeM6Jsw72m7L0MezZ6mdcwXSmaexbznCY=; b=uNboutYzV2kKNlujlhQ6ZbkUc1nEWZThJyz792Mk8hdhTBRP8+heTX3aZOPxvqCNtS 0MyFLiuvztu1X/K20urpsu07MSoihpMdpIlEOtjeAzblJZpGv67wckskkHaAFmFZcuAd 6v++tiYmTwixXPxUHEgHVHaSgsFEgxfp29iwg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=WMnCnNcdP8o/qkauVid+jpcqeLFye1aukayXbfuPkATpzxb+WxhDN7JHreixg3pvPm NNahRe76FHdBZuU9KuvFWfhT5I77DN/ytuF7Iy4Pwz6xAnhguNvfuVZ/rCI+s8STol51 pKKr95xwXu98j+Rw1h0xhqBbtf719FtC4+x6g= MIME-Version: 1.0 Received: by 10.223.118.9 with SMTP id t9mr5321351faq.20.1236687395083; Tue, 10 Mar 2009 05:16:35 -0700 (PDT) In-Reply-To: <3786f7bb0903100511t5fe45b63tbe84b502b0d64bbc@mail.gmail.com> References: <005901c9a178$d00c3c20$7024b460$@com> <3786f7bb0903100511t5fe45b63tbe84b502b0d64bbc@mail.gmail.com> Date: Tue, 10 Mar 2009 13:16:35 +0100 Message-ID: <162867790903100516i1e259d1bl1273c13b25515d9a@mail.gmail.com> Subject: Re: [GENERAL] How to Convert VarChar to Date in PgSQL From: Pavel Stehule To: Jaume Sabater Cc: Venkat Rao Tammineni , pgsql-general@postgresql.org, pgsql-admin@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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/130 X-Sequence-Number: 31630 2009/3/10 Jaume Sabater : > On Tue, Mar 10, 2009 at 1:07 PM, Venkat Rao Tammineni > wrote: > >> =C2=A0 I have one table which has lot of data.In the same table I have o= ne >> 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. > > An easy solution would be to add a new column to the table, of type > date, and then execute an update statement that reads, for each row, > the value in the varchar field and writes the converted value to the > date field. > resp. alter table someatb alter column columname type date using to_data(columname, 'YYYY-MM-DD'); regards Pavel > -- > Jaume Sabater > http://linuxsilo.net/ > > "Ubi sapientas ibi libertas" > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general >