X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C547252AC5 for ; Thu, 14 Jul 2005 15:23:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62034-04 for ; Thu, 14 Jul 2005 18:22:57 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) by svr1.postgresql.org (Postfix) with ESMTP id 9E9D6529F3 for ; Thu, 14 Jul 2005 15:22:56 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id i36so478797wra for ; Thu, 14 Jul 2005 11:22:57 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=j61+//tcFzqluIODTUZbvlEbkwLKUA524kxIbTwR95CktUiyyXOTawmX+kT+I8j2lPRm4TcuXmJf6lVI3K8ZDblm9lMyF5SQ+iSGv7QkAm2GXjwwogmaUJhL0jUS3mVbYxtsLKckaM2y9RxJwVlCV2VnETYghqWVvOiXs2MzAgM= Received: by 10.54.23.49 with SMTP id 49mr841422wrw; Thu, 14 Jul 2005 11:22:10 -0700 (PDT) Received: by 10.54.86.16 with HTTP; Thu, 14 Jul 2005 11:22:10 -0700 (PDT) Message-ID: <90876a9e0507141122463cb054@mail.gmail.com> Date: Thu, 14 Jul 2005 12:22:10 -0600 From: Christian Cryder Reply-To: Christian Cryder To: pgsql-jdbc@postgresql.org Subject: Re: Timezone conversion woes In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200507/86 X-Sequence-Number: 13234 Hi Reid, I am having a hard time locating this section (6.8.3) in the documentation (I'm looking both here: http://www.postgresql.org/docs/8.0/interactive/index.html and here: http://jdbc.postgresql.org/documentation/80/index.html and not seeing it in either place.) Where should I be looking? Regarding the AT TIME ZONE option, it looks like that is specific to Postgres, and works with the select, yes? My problem here is that I am reading from MS SQL and trying to _write_ to Postgres. So I'm not sure how this would help me. Can anyone tell me if its possible to read a Date/Time/Timestamp as a "bytes" value and then write it back that way somehow? Any other suggestions? THanks much, Christian On 7/14/05, Reid Thompson wrote: > Christian Cryder wrote: > > Ok, let me see if I can explain this simply. Is there any way > > to read/write JDBC date/time/timestamp data through the > > postgres drivers WITHOUT having any timezone conversion issues? > > > > I've searched high and low for info on this and not found any > > conclusive answers. > > > > What is driving this problem is that we are reading data out > > of one DB (MS SQL, using Net Direct drivers), and writing it back > > into Postgres 8. > > > > In most cases, the NetDirect drivers leave timezone info > > alone, EXCEPT when the date in question happens to fall into > > a daylight savings time issue. In other words, when reading a > > "zoneless" time out of the db, NetDirect says "hey, that's > > not a valid time, because it falls into daylight savings time > > "no mans land" (between 2-3 AM, 1st Sunday of April), and so > > it rolls it forward to what it considers a valid time. The > > only way we have found to offset this is to tell the JVM we > > are running in UTC. Then NetDirect doesn't do the conversion. > > > > However, as soon as we do this, we now have a problem on the > > Postgres side - Postgres says "oh, you're running in UTC, but > > the DB is running as MST, so I better convert that date for > > you." Argh. No, that is not what we want. We can compensate > > by telling Postgres to run in UTC, but that's not really what > > we want to do either (ie. because then, any code that writes > > data into the DB has to remember to set its jvm timezone to UTC as > > well). > > > > What we really want to do here is just tell the drivers - > > "leave my dates alone, pal!" Is there any way to do that? I > > realize that the NetDirect behavior is kind of at the root of > > this, but we haven't found any way to change that. So please > > don't just say - "your screwed". Our goal is to sucessfully > > migrate to Postgres, here, so I'd really appreciate solutions rather > > than finger pointing. > > > > Any suggestions? > > > > Thanks, > > Christian > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 3: Have you checked our extensive FAQ? > > > http://www.postgresql.org/docs/faq >=20 > would this be of use >=20 > 6.8.3. AT TIME ZONE >=20 > The AT TIME ZONE construct allows conversions of timestamps to different > timezones. >=20 > Table 6-19. AT TIME ZONE Variants > Expression Returns Description > timestamp without time zone AT TIME ZONE zone timestamp with time zone > Convert local time in given timezone to UTC > timestamp with time zone AT TIME ZONE zone timestamp without time > zone Convert UTC to local time in given timezone > time with time zone AT TIME ZONE zone time with time zone Convert > local time across timezones >=20 > In these expressions, the desired time zone can be specified either as a > text string (e.g., 'PST') or as an interval (e.g., INTERVAL '-08:00'). >=20 > Examples (supposing that TimeZone is PST8PDT): >=20 > SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST'; > Result: 2001-02-16 19:38:40-08 >=20 > SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE > 'MST'; > Result: 2001-02-16 18:38:40 >=20 > The first example takes a zone-less timestamp and interprets it as MST > time (GMT-7) to produce a UTC timestamp, which is then rotated to PST > (GMT-8) for display. The second example takes a timestamp specified in > EST (GMT-5) and converts it to local time in MST (GMT-7). >=20 > The function timezone(zone, timestamp) is equivalent to the > SQL-compliant construct timestamp AT TIME ZONE zone. >=20 > reid >