pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christian Cryder <c.s.cryder@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Timezone conversion woes
Date: Thu, 14 Jul 2005 12:22:10 -0600
Message-ID: <90876a9e0507141122463cb054@mail.gmail.com> (raw)
In-Reply-To: <F71C0DC6B4FD3648815AAA7F969E352901530B2F@sr002-2kexc.ateb.com>
References: <F71C0DC6B4FD3648815AAA7F969E352901530B2F@sr002-2kexc.ateb.com>

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 <Reid.Thompson@ateb.com> 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
> 
> would this be of use
> 
> 6.8.3. AT TIME ZONE
> 
> The AT TIME ZONE construct allows conversions of timestamps to different
> timezones.
> 
> 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
> 
> 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').
> 
> Examples (supposing that TimeZone is PST8PDT):
> 
> SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST';
>  Result: 2001-02-16 19:38:40-08
> 
>  SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE
> 'MST';
>  Result: 2001-02-16 18:38:40
> 
> 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).
> 
> The function timezone(zone, timestamp) is equivalent to the
> SQL-compliant construct timestamp AT TIME ZONE zone.
> 
> reid
>



view thread (11+ messages)  latest in thread

Message-ID: <90876a9e0507141122463cb054@mail.gmail.com>
Permalink:  ../90876a9e0507141122463cb054@mail.gmail.com/
Also on:    postgresql.org/message-id/90876a9e0507141122463cb054@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: c.s.cryder@gmail.com
  Subject: Re: Timezone conversion woes
  In-Reply-To: <90876a9e0507141122463cb054@mail.gmail.com>
  References: <F71C0DC6B4FD3648815AAA7F969E352901530B2F@sr002-2kexc.ateb.com> <90876a9e0507141122463cb054@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox