From: Tom Lane <tgl@sss.pgh.pa.us>
To: kenzoid@io.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Timezone issue with date_part
Date: Sat, 02 Nov 2002 09:17:14 -0500
Message-ID: <20169.1036246634@sss.pgh.pa.us> (raw)
In-Reply-To: <20021102065654.GA8564@roark.kenzoid.com>
References: <20021102065654.GA8564@roark.kenzoid.com>
Ken Kennedy <kkennedy@kenzoid.com> writes:
> [ date_part('epoch') is wrong for a timestamp value ]
The epoch value is really only correct for a TIMESTAMP WITH TIME ZONE
value. If you apply date_part('epoch') to a timestamp without time zone,
as you appear to be doing here, what you will get is the epoch for the
given value interpreted as GMT.
A hack solution is to cast the value to TIMESTAMP WITH TIME ZONE before
extracting the epoch; the cast will assume that the given value is local
time. But a better idea is to store the column as TIMESTAMP WITH TIME
ZONE in the first place.
(IMHO, the SQL spec is really brain-dead to define timestamp without
time zone as the default form of timestamp; the variant with time zone
is much more useful for most applications. It's far too easy to shoot
yourself in the foot when working with zoneless timestamps --- usually
in a way that you won't notice until daylight-savings transition time
comes around, or you roll out the app to users in other time zones.)
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, kenzoid@io.com
Subject: Re: Timezone issue with date_part
In-Reply-To: <20169.1036246634@sss.pgh.pa.us>
* 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