Re: Inserting timestamp values from windowz application

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: cnliou(at)so-net(dot)net(dot)tw
Cc: "" <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Inserting timestamp values from windowz application
Date: 2003-12-02 18:06:25
Message-ID: 22898.1070388385@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

"cnliou" <cnliou(at)so-net(dot)net(dot)tw> writes:
> After project1.exe connects to postgres via libpq.dll, the
> query
> SHOW TIME ZONE
> returns "unknown", which is as expected. Then I do the
> insert from project1.exe:
> INSERT INTO test VALUES (CAST('2003-1-1' AS TIMESTAMP));
> What weird is that this datetime value is saved to column c1
> as 2002-12-31 16:00:00 UTC.

This means that your system default timezone is UTC+8.

The fact that SHOW TIME ZONE returns "unknown" does not mean that your
time zone setting is UTC. It means that the standard C library
interface doesn't provide any way to find out the setting in string
form :-(. SHOW TIME ZONE can tell you something useful if either
(1) you've done a SET TIME ZONE, or (2) the variable TZ is
defined in the postmaster's environment. Otherwise it says "unknown"
... but the C library nonetheless will find a time zone setting from
someplace.

> I need a "manual" way to explicitly tell postgres the
> client's time zone by sending from project1.exe the query
> "SET TIME ZONE -5" or the like to postgres.

What's so hard about that?

regards, tom lane

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Cal McPherson 2003-12-03 22:49:56
Previous Message cnliou 2003-12-02 17:27:36 Inserting timestamp values from windowz application