Re: Daylight savings time confusion

From: "Rob Richardson" <Rob(dot)Richardson(at)rad-con(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Cc: "Ward Eaton" <Ward(dot)Eaton(at)rad-con(dot)com>, "Daniel S(dot) Messina" <Dan(dot)Messina(at)rad-con(dot)com>, "Tim Kelly" <Tim(dot)Kelly(at)rad-con(dot)com>
Subject: Re: Daylight savings time confusion
Date: 2010-03-22 13:08:40
Message-ID: 04A6DB42D2BA534FAC77B90562A6A03D012F4C05@server.rad-con.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom,

You said, "It seems to me that you're not entirely understanding how
timestamps work in Postgres." That is an understatement!

Thank you very much for your explanation. I have forwarded it to the
other members of my development group, with my suggestion that we follow
your ideas for future projects. I am not sure how easy it will be to
retrofit existing projects, but I am sure it should be done.

One question: We have customers all over the world. It would be best
if we could rely on the operating system (usually Windows Server 2003)
to tell us what time zone we're in, rather than asking for a specific
timezone when we want to know a wallclock time. Is that possible? If
not, it's not that big a deal because our database includes a table
named system_info that contains a single record describing the
customer's environment. We could just add a timezone field to that
table. But how would we do that? What data type should that column
have, and what would a query look like that converts a time from UTC to
local time based on that field?

As I was typing that question, I think I came up with the answer: the
question is irrelevant. The reason for having a field to store times in
UTC is so that intervals between times can be calculated without
worrying about daylight savings time. But Postgres will take the
timezone into account when calculating intervals, so there is no reason
at all to store a UTC version of the time.

And, as you pointed out, storing the same value twice is horrible
database design.

RobR

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message william wayne 2010-03-22 13:33:44 Holger Kalbas
Previous Message Tom Lane 2010-03-22 12:18:08 Re: Determining the OID of a certain type