Received: from maia.hub.org (maia-1.hub.org [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 8DA236334C0 for ; Thu, 29 Apr 2010 05:00:10 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 78557-06 for ; Thu, 29 Apr 2010 07:59:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pv0-f174.google.com (mail-pv0-f174.google.com [74.125.83.174]) by mail.postgresql.org (Postfix) with ESMTP id A1A5E6332F2 for ; Thu, 29 Apr 2010 04:59:57 -0300 (ADT) Received: by pva4 with SMTP id 4so5090pva.19 for ; Thu, 29 Apr 2010 00:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=9Qdh36uAsaX4sgl5oXd1SrBUJxmCxBF9i+ckYAdJWLc=; b=EGfaIvMfym9Xyok0+BB71Ut4Au2f5NAVJMu0oyPfDZGsaZWs6h9vInZkU4xsEjGtjm SSl3y2zaBgYRPZvr0rg5rFyglezvz0oRcFE7MyaPgw2/B93+dupk6jZsJkyMcxza06pL 6Iz33tSYElUZTBPb8WnakgiYFkUMTp0JD3acQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=vJGgzbDqlD3obE0stMEBibeyGxUn26hXIVyf3gRApSDppJm02lJnx2nLMMwH+jP5sp 0uVeKFwdcA1Oa+FAb+gK06xlBsyxUbNRgaJ5qfBHbYLOSLEMq6h2SeAWj6au48h9h4/h AMEROvxpolt1viI1EqDH5r3D6XZJTOsgSwtVU= Received: by 10.141.100.17 with SMTP id c17mr9428946rvm.0.1272527967127; Thu, 29 Apr 2010 00:59:27 -0700 (PDT) Received: from [10.177.177.104] (ip98-176-245-156.sd.sd.cox.net [98.176.245.156]) by mx.google.com with ESMTPS id b10sm317468rvn.3.2010.04.29.00.59.24 (version=SSLv3 cipher=RC4-MD5); Thu, 29 Apr 2010 00:59:25 -0700 (PDT) Message-ID: <4BD93C4D.20807@gmail.com> Date: Thu, 29 Apr 2010 00:59:09 -0700 From: Edward Ross Reply-To: efrossuhl@gmail.com User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: Tom Lane CC: pgsql-sql@postgresql.org Subject: Re: problem converting strings to timestamps with time zone References: <4BD8FCA6.1020901@gmail.com> <853.1272512343@sss.pgh.pa.us> In-Reply-To: <853.1272512343@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201004/111 X-Sequence-Number: 34038 Tom Lane wrote: > Edward Ross writes: >> Here is a sandbox example of what I mean. > >> CREATE TABLE test_0 >> ( >> string_value varchar(2047), >> timestamp_value timestamp with time zone >> ); > >> insert into test_0 >> (string_value) >> values >> ('2010-03-12 17:06:21-0800'), >> ('2009-08-14 16:47:40+0500'), >> ('2010-03-22 22:45:59-0400'); > >> As expected, select * from test_0; , produces the following: > >> string_value timestamp_value >> 2010-03-12 17:06:21-0800 >> 2009-08-14 16:47:40+0500 >> 2010-03-22 22:45:59-0400 > >> I would like to parse the strings into their equivalent timestamps >> and put them in the timestamp_value column. > >> My attempt, so far, to update the table: > >> update value >> set >> timestamp_value = >> to_timestamp(string_value, 'YYYY-MM-DD HH24:MI:SS-XXXX'); > > Forget to_timestamp; just cast the string to timestamptz. The > regular timestamp input converter will handle that format fine. > > regards, tom lane > That worked great. Thanks very much, Edward Ross