Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 317AB1288B2D for ; Wed, 1 Feb 2012 12:00:50 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rscc4-0006wy-Pt for pgsql-bugs@postgresql.org; Wed, 01 Feb 2012 16:00:49 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q11G0Pkg015145; Wed, 1 Feb 2012 11:00:25 -0500 (EST) To: o.bousche@krohne.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6424: Possible error in time to seconds conversion In-reply-to: References: Comments: In-reply-to o.bousche@krohne.com message dated "Wed, 01 Feb 2012 14:15:02 +0000" Date: Wed, 01 Feb 2012 11:00:25 -0500 Message-ID: <15144.1328112025@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/6 X-Sequence-Number: 32349 o.bousche@krohne.com writes: > Should the query > select > extract(epoch > from cast('2012-01-01 14:30:1' as > timestamp) - > cast('1970-01-01 0:0:0' as > timestamp))) - > extract(epoch > from (cast('2012-01-01 14:30:1' as > timestamp))) > return 0 instead of 3600? Well, right now it's operating as designed, because extract(epoch, timestamp without timezone) tries to rotate the timestamp from local time to GMT so that "epoch 0" corresponds to midnight GMT 1970-01-01. (I presume that you are in a GMT+1 timezone.) Changing that behavior is one of the possible solutions to the problem being discussed over here: http://archives.postgresql.org/pgsql-general/2012-01/msg00649.php but I don't believe we have any consensus yet about whether that would be a good idea. regards, tom lane