Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 6867A930E1E for ; Fri, 3 Aug 2012 07:56:06 -0300 (ADT) Received: from 10610.x.rootbsd.net ([204.109.60.69] helo=vps001.shopzeus.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SxFY2-0006WN-Fx for pgsql-admin@postgresql.org; Fri, 03 Aug 2012 10:56:05 +0000 Received: from [192.168.1.105] (localhost [127.0.0.1]) by vps001.shopzeus.com (8.14.3/8.14.3) with ESMTP id q73Atow2065691 for ; Fri, 3 Aug 2012 06:55:51 -0400 (EDT) (envelope-from gandalf@shopzeus.com) Message-ID: <501BAE33.4090102@shopzeus.com> Date: Fri, 03 Aug 2012 12:55:47 +0200 From: Laszlo Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: Messed up time zones References: <501B8C6F.6040100@shopzeus.com> <501BAA84.9010306@shopzeus.com> In-Reply-To: <501BAA84.9010306@shopzeus.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/22 X-Sequence-Number: 39843 Here is a better example that shows what I actually have in my database. Suppose I have this table, with UTC timestamps in it: template1=> create table test ( a timestamptz not null primary key ); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" for table "test" CREATE TABLE template1=> insert into test values ('2011-10-30 00:00:00'::timestamp at time zone 'UTC'); INSERT 0 1 template1=> insert into test values ('2011-10-30 01:00:00'::timestamp at time zone 'UTC'); INSERT 0 1 template1=> set datestyle to "postgres, postgres"; SET template1=> select * from test; a ------------------------------ Sun Oct 30 00:00:00 2011 UTC Sun Oct 30 01:00:00 2011 UTC (2 rows) I would like to see the same values, just converted into a different time zone. But still have timestamptz type! So I try this: template1=> select a at time zone 'Europe/Budapest' from test; timezone -------------------------- Sun Oct 30 02:00:00 2011 Sun Oct 30 02:00:00 2011 (2 rows) Which is not good, because the zone information was lost, and so I see identical values, but they should be different. Casting to timestamptz doesn't help either, because casting happens after the time zone information was lost: template1=> select (a at time zone 'Europe/Budapest')::timestamptz from test; timezone ------------------------------ Sun Oct 30 02:00:00 2011 UTC Sun Oct 30 02:00:00 2011 UTC (2 rows) template1=> So how do I create a query that results in something like: a ------------------------------ Sun Oct 30 02:00:00 2011 +0500 Sun Oct 30 02:00:00 2011 +0600 (2 rows)