From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
Cc: | Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>, David Fetter <david(at)fetter(dot)org>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: Small documentation patch |
Date: | 2003-12-03 15:49:01 |
Message-ID: | 192.1070466541@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> writes:
> Whoops:
> SELECT 1070430858::abstime::timestamp;
Or you can do
SELECT '1070430858'::int4::abstime::timestamp;
which helps expose the fact that you're really depending on the
int4-to-abstime binary equivalence. This will certainly break in
2038...
The originally proposed documentation patch is flat wrong:
SELECT 'epoch'::timestamp + '1070430858 seconds'::interval;
because it will produce a timestamp without time zone, thus effectively
making the epoch be 1970-1-1 midnight local time. But of course the
correct Unix epoch is 1970-1-1 midnight GMT. So correct code is
SELECT 'epoch'::timestamptz + '1070430858 seconds'::interval;
or you could use
SELECT 'epoch'::timestamptz + 1070430858 * '1 second'::interval;
which has the advantage that it works without weird concatenation
pushups when the numeric value is coming from a variable.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | David Fetter | 2003-12-03 16:00:21 | Re: Small documentation patch |
Previous Message | Randolf Richardson | 2003-12-03 10:20:23 | Re: ISO 8601 'Time Intervals' of the 'format with time-unit deignators' |