X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 082AC53A8D for ; Sun, 3 Apr 2005 04:50:43 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70424-01 for ; Sun, 3 Apr 2005 03:50:33 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0A65B52A82 for ; Sun, 3 Apr 2005 04:50:32 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j333oa10008223; Sat, 2 Apr 2005 22:50:36 -0500 (EST) To: James G Wilkinson Cc: pgsql-sql@postgresql.org Subject: Re: Date/Time Conversion In-reply-to: <4249ED1F.6080909@alpinegeophysics.com> References: <4249ED1F.6080909@alpinegeophysics.com> Comments: In-reply-to James G Wilkinson message dated "Tue, 29 Mar 2005 16:04:47 -0800" Date: Sat, 02 Apr 2005 22:50:36 -0500 Message-ID: <8222.1112500236@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/21 X-Sequence-Number: 20914 James G Wilkinson writes: > beta_jgw=# update scenario1.time_test set local_day = extract(day from > to_timestamp(to_char(gmt_date,'YYYY-MM-DD')||' > '||to_char(gmt_hour,'99')||':00:00-00','YYYY-MM-DD HH24:MI:SS') at time > zone 'EST'); That seems like a mighty ugly way to do it; have you considered some kind of timestamp arithmetic instead? But anyway, I suspect your problem is you need a few 'FM' format specs to keep the to_char functions from introducing unwanted spaces. Look at the intermediate results of your expressions. regards, tom lane