Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id BC82F9FB345 for ; Thu, 5 Oct 2006 17:02:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 76536-05 for ; Thu, 5 Oct 2006 20:01:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from talk.nabble.com (www.nabble.com [72.21.53.35]) by postgresql.org (Postfix) with ESMTP id 84C549FB332 for ; Thu, 5 Oct 2006 17:01:38 -0300 (ADT) Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1GVZPV-0007pv-AH for pgsql-sql@postgresql.org; Thu, 05 Oct 2006 13:01:37 -0700 Message-ID: <6667349.post@talk.nabble.com> Date: Thu, 5 Oct 2006 13:01:37 -0700 (PDT) From: chrisj To: pgsql-sql@postgresql.org Subject: Re: Assigning a timestamp without timezone to a timestamp In-Reply-To: <8C5B026B51B6854CBE88121DBF097A864DE848@ehost010-33.exch010.intermedia.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: chrisj.wood@sympatico.ca References: <6613652.post@talk.nabble.com> <20061003135623.GB3191@phlogiston.dyndns.org> <6621346.post@talk.nabble.com> <20061003145134.GA3399@phlogiston.dyndns.org> <8C5B026B51B6854CBE88121DBF097A864DE848@ehost010-33.exch010.intermedia.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200610/69 X-Sequence-Number: 26458 Hi Hector, It would probably better to get the explanation from Andrew, but I will do the best I can. You asked about the 1 and -3. The 1 would be the store number in my original scenario and -3 would be the representation of the timezone (three hours behind Universal Coordinate Time). I still have not had a chance to implement the solution into my application, but I am assuming the -3 could also be a mnemonic such as "EDT" I live in Toronto EDT is Eastern Daylight-savings Time. As for the syntax of the select, it is simply casting a character representation of a timestamp concatenated with a character representation of timezone to timestamptz. In hindsight it is so simple I can't believe I could not come up with it myself. Hector Villarreal wrote: > > Hi > I am also interested in this type of setup. However, in the example > below > I am a little confused as to why the table entry is 1, -3 > And the subsequent select statement . I would appreciate an explanation > on the select statement. I do not understand the syntax. > Thanks in advance > Hector Villarreal > SELECT a.timestamp::timestamptz from (SELECT '2006-10-03 > 09:00'||"timezone" as timestamp from storetz where id = 1) as a; > timestamp > > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Andrew Sullivan > Sent: Tuesday, October 03, 2006 7:52 AM > To: chrisj > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] Assigning a timestamp without timezone to a timestamp > > On Tue, Oct 03, 2006 at 07:26:52AM -0700, chrisj wrote: >> location, but they are the directive to all store locations saying: > "In the >> context of the timezone your store is located in, these are the hours > you >> should be open. > > Ah. Well, then, right, it _does_ have to be timezone free. That's > actually the only case I'd use that. Sorry, I'm dim, and didn't > understand properly what you were doing. (I read the "relative to > the store's own time zone" to refer to the corporate office. No, I > don't know why, either. Told you I'm dim.) > > Anyway, here's something that worked for me (expanding this into your > case ought not to be too tricky): > > testing=# SELECT * from storetz ; > id | timezone > ----+---------- > 1 | -03 > (1 row) > > testing=# SELECT a.timestamp::timestamptz from (SELECT '2006-10-03 > 09:00'||"timezone" as timestamp from storetz where id = 1) as a; > timestamp > ------------------------ > 2006-10-03 12:00:00+00 > (1 row) > > A > -- > Andrew Sullivan | ajs@crankycanuck.ca > When my information changes, I alter my conclusions. What do you do > sir? > --attr. John Maynard Keynes > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > > -- View this message in context: http://www.nabble.com/Assigning-a-timestamp-without-timezone-to-a-timestamp-with-timezone-tf2373845.html#a6667349 Sent from the PostgreSQL - sql mailing list archive at Nabble.com.