X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C355E9DC93F for ; Fri, 3 Mar 2006 20:32:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89495-06 for ; Fri, 3 Mar 2006 20:32:30 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 9C0789DC83F for ; Fri, 3 Mar 2006 20:32:24 -0400 (AST) 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 k240WPZB009494; Fri, 3 Mar 2006 19:32:25 -0500 (EST) To: "Davidson, Robert" cc: pgsql-sql@postgresql.org Subject: Re: Getting yyyy-mm-dd 00:00:00 in an arbitrary time zone In-reply-to: References: Comments: In-reply-to "Davidson, Robert" message dated "Fri, 03 Mar 2006 16:13:04 -0800" Date: Fri, 03 Mar 2006 19:32:25 -0500 Message-ID: <9493.1141432345@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.112 required=5 tests=[AWL=0.112] X-Spam-Score: 0.112 X-Spam-Level: X-Archive-Number: 200603/84 X-Sequence-Number: 24430 "Davidson, Robert" writes: > I am trying to find out what the last full day of data for an arbitrary = > timezone (generally not the pg client's timezone). I get the = > max(timestamp), then would like to remove the time portion. Sounded like = > a job for date_trunc, unfortunately date_trunc is not timezone aware: > select (date_trunc('day', '2006-01-31 23:00:00-800' at time zone 'CST')) = > at time zone 'CST' > 2006-01-31 22:00:00-08 > Since the client is in PST, the truncated date is returned as 2006-02-01 = > PST which is two hours before the desired time. You're being quite unclear about what you want, but AFAICS the above expression does exactly what you asked for. Namely, you get a time that is midnight in the CST zone and then is adjusted to your current timezone for display. Perhaps you could be more clear about why you don't like this result? regards, tom lane