From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | kenzoid(at)io(dot)com |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Timezone issue with date_part |
Date: | 2002-11-02 14:17:14 |
Message-ID: | 20169.1036246634@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Ken Kennedy <kkennedy(at)kenzoid(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander M. Pravking | 2002-11-02 14:33:35 | Re: Different size in the DATA directory |
Previous Message | Ken Kennedy | 2002-11-02 06:56:54 | Timezone issue with date_part |