Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 7F8A91337BD0 for ; Fri, 18 Mar 2011 13:07:45 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 52431-04 for ; Fri, 18 Mar 2011 16:07:37 +0000 (UTC) X-Greylist: delayed 00:06:06.2874 by SQLgrey-1.7.6 Received: from nm27.bullet.mail.sp2.yahoo.com (nm27.bullet.mail.sp2.yahoo.com [98.139.91.97]) by mail.postgresql.org (Postfix) with SMTP id 770291337BA3 for ; Fri, 18 Mar 2011 13:07:37 -0300 (ADT) Received: from [98.139.91.62] by nm27.bullet.mail.sp2.yahoo.com with NNFMP; 18 Mar 2011 16:01:30 -0000 Received: from [98.136.185.29] by tm2.bullet.mail.sp2.yahoo.com with NNFMP; 18 Mar 2011 16:01:30 -0000 Received: from [127.0.0.1] by smtp110.mail.gq1.yahoo.com with NNFMP; 18 Mar 2011 16:01:30 -0000 X-Yahoo-Newman-Id: 107636.31130.bm@smtp110.mail.gq1.yahoo.com Received: from jonathanlaptop (JB@67.34.121.27 with login) by smtp110.mail.gq1.yahoo.com with SMTP; 18 Mar 2011 09:01:29 -0700 PDT X-Yahoo-SMTP: 44.80yyswBBWn2mP4eIs.OiF0CguW7wtDDCwTEpCAZ4GQXK1x4I- X-YMail-OSG: AaOORQ0VM1m5VryWH6XhtXKkbeW.t.R33xrnWdFiyHi9e54 TRSUYjcL727fk3HPP.7MWkECXz.XuC7.suz7N1YjWyWgPwdG51JwAGNLcQiJ Qrs.xgKQXzmn6FBe0oqupW6UUQLBumeuFwaD3TWCrrGId0k9wI.fvc45PFrS cV.COI3672VgVSKJocrhTkqkA.d71ZrjNOFYcz7zfY9Ykqo3xUmcbJmommMy yH5sMEHzQl_3NNkO4REvMTKz..pHK149amZ4iwWorNF5o1DbL6W3ZJdkIjhS YiAbi5KwmNwHPeTGy0sx6PdYuAZ7fldJf1yA2PYkf X-Yahoo-Newman-Property: ymail-3 Reply-To: From: "Jonathan Brinkman" To: "'Tom Lane'" Cc: References: <004c01cbe57c$7d920ca0$78b625e0$@com> <15708.1300462903@sss.pgh.pa.us> In-Reply-To: <15708.1300462903@sss.pgh.pa.us> Subject: Re: TO_CHAR(timestamptz,datetimeformat) wrong after DST change Date: Fri, 18 Mar 2011 12:01:25 -0400 Organization: BlackSky Technologies, Inc. Message-ID: <005601cbe585$bc7d4b10$3577e130$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acvlg1WciAfkaVYyR/qm3tMLm2FtPgAAaD+A Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, UNPARSEABLE_RELAY=0.001 X-Spam-Level: X-Archive-Number: 201103/248 X-Sequence-Number: 29758 When in a command prompt I log into psql with merely "psql" and get postgres=#, and run SELECT now(); I get the correct time. When I log into my application's database with psql beta_cms_gate and get beta_cms_gate=# prompt, and run SELECT now(); I get incorrect time (still -05 timezone, and 1 hour too early). When I use psql and show time zone; I get "America/New_York". When I use psql beta_cms_gate and show time zone; I get "EST". I guess EST is not DST-friendly? My postgresql.conf is set to "America/New York". Within my DB I ran set time zone 'America/New_York'; and retried the select now(), and now it is correct. -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Friday, March 18, 2011 11:42 AM To: JB@BlackSkyTech.com Cc: pgsql-bugs@postgresql.org Subject: Re: [BUGS] TO_CHAR(timestamptz,datetimeformat) wrong after DST change "Jonathan Brinkman" writes: > My TO_CHAR function is now an hour off thanks to Daylight Savings Time. > The dates are correct (I'm in EST: TZ=-04) but my function now returns TIME > an hour early. > (prior to DST we were TZ=-05). > TIMESTAMPTZ data (v_dt): 2011-03-17 18:21:50-04 > FUNCTION SNIPPET: to_char(v_dt, 'mm/dd/yyyy hh:mi AM') > FUNCTION RETURNS: 03/18/2011 09:21 AM > FUNCTION SHOULD RETURN: 03/18/2011 10:21 AM > postgres=# show time zone; > TimeZone > ------------------ > America/New_York > (1 row) Works for me: regression=# set timezone = 'America/New_York'; SET regression=# select now(); now ------------------------------- 2011-03-18 11:39:45.124162-04 (1 row) regression=# select to_char(now(), 'mm/dd/yyyy hh:mi AM'); to_char --------------------- 03/18/2011 11:39 AM (1 row) Are you sure your application is running with the timezone setting you think it is? regards, tom lane