Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 4768E930E1E for ; Fri, 3 Aug 2012 12:24:07 -0300 (ADT) Received: from 10610.x.rootbsd.net ([204.109.60.69] helo=vps001.shopzeus.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SxJjR-0004Go-S8 for pgsql-admin@postgresql.org; Fri, 03 Aug 2012 15:24:06 +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 q73FNsYX085363 for ; Fri, 3 Aug 2012 11:23:55 -0400 (EDT) (envelope-from gandalf@shopzeus.com) Message-ID: <501BED07.5070603@shopzeus.com> Date: Fri, 03 Aug 2012 17:23:51 +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> <501BAE33.4090102@shopzeus.com> <16399.1344003584@sss.pgh.pa.us> In-Reply-To: <16399.1344003584@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/24 X-Sequence-Number: 39845 On 2012-08-03 16:19, Tom Lane wrote: > Laszlo Nagy writes: >> 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) > Set the "timezone" setting to the zone you have in mind, and then just > print the values. majorforms=> set time zone 'Europe/Budapest'; SET majorforms=> select * from test; a ------------------------ 2011-10-30 02:00:00+02 2011-10-30 02:00:00+01 (2 rows) majorforms=> It works. Thank you! So is it impossible to construct a query with columns that are different time zones? I hope I'm not going to need that. :-) > The reason there's no manual way to do rotation > across zones is that there's no need for one because it's done > automatically during printout of a timestamptz value. I can come up with an example when it would be needed. For example, consider a company with two sites in different time zones. Let's say that they want to store time stamps of online meetings. They need to create a report that shows the starting time of the all meetings *in both zones*. I see no way to do this in PostgreSQL. Of course, you can always select the timestamps in UTC, and convert them into other time zones with a program so it is not a big problem. And if we go that route, then there is not much point in using the timestamptz type, since we already have to convert the values with a program... > > I suspect that you have not correctly internalized what timestamptz > values actually are. Internally they are just time values specified in > UTC (or UT1 if you want to be picky). On input, the value is rotated > from whatever zone is specified in the string (or implicitly specified > by "timezone") to UTC. On output, the value is rotated from UTC to > whatever the current "timezone" setting is. Oh I see. So actually they don't store the zone? I have seen that timestamptz and timestamp both occupy 8 bytes, but I didn't understand completely. It also means that if I want to store the actual time zone (in what the value was originally recorded), then I have to store the zone in a separate field. Later I can convert back to the original time zone, but only with an external program. Fine with me. I'm happy with this, just I did not understand how it works. Thanks, Laszlo