Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 48CCB1337BD6 for ; Tue, 3 May 2011 12:54:39 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 20683-02 for ; Tue, 3 May 2011 15:54:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from polaris.pinpointresearch.com (cerberus.pinpointresearch.com [66.7.238.130]) by mail.postgresql.org (Postfix) with ESMTP id 6F84513364DE for ; Tue, 3 May 2011 12:54:31 -0300 (ADT) Received: from betelgeuse.pinpointresearch.com (betelgeuse.pinpointresearch.com [192.168.1.179]) by polaris.pinpointresearch.com (Postfix) with ESMTP id EDBF8E00EC83; Tue, 3 May 2011 08:54:29 -0700 (PDT) Message-ID: <4DC02535.3070106@pinpointresearch.com> Date: Tue, 03 May 2011 08:54:29 -0700 From: Steve Crawford User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: LaraK CC: pgsql-sql@postgresql.org Subject: Re: convert in GMT time zone without summer time References: <1302848430605-4304830.post@n5.nabble.com> <4DAC6D4D.30405@pinpointresearch.com> <1304406921088-4366565.post@n5.nabble.com> In-Reply-To: <1304406921088-4366565.post@n5.nabble.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/18 X-Sequence-Number: 35302 On 05/03/2011 12:15 AM, LaraK wrote: > Very good! > > Another question: > I want to convert the string to the type TIMESTAMP WITH TIME ZONE. What do I > have to format? 'TZ' does not. > > select to_timestamp('2011-03-22 14:17:00 Europe/Berlin', 'YYYY-MM-DD > HH:MI:SS TZ') > Just cast it to a timestamp with time zone: select timestamptz '2011-04-22 19:17:00 Europe/Berlin'; Remember... The value of a timestamp with time zone is always stored internally as UTC. When a timestamp with time zone is displayed, the time zone is based on the client's default, the "set timezone to" statement or the "at time zone" clause in the query. In the case of an explicit "at time zone" clause, the result becomes a timestamp without time zone data type (that is why the previous static example with the "at time zone" clause was a timestamp without time zone). A timestamp with time zone is useful to identify a specific point in time. "Bin Laden's death was announced at...", "shuttle Endeavor launched at...", "Amazon EC2 crashed at...". Most timestamp data I encounter is of this type. A timestamp without time zone might be useful for data like "Breakfast is served at 7am". Presumably a hotel chain would serve at 7am in each hotel and not have all hotels serve at 7am corporate headquarters time. It takes a bit of time to wrap your head around time and time zones but it would be well worth your time to carefully read http://www.postgresql.org/docs/8.4/interactive/datatype-datetime.html (IIRC, you are using 8.4) a couple times. Cheers, Steve