From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomasz Myrta <jasiek@klaster.net>
Cc: MichaelHoeller@t-online.de
Cc: pgsql-sql@postgresql.org
Subject: Re: date calculation
Date: Fri, 22 Aug 2003 08:56:50 -0400
Message-ID: <6305.1061557010@sss.pgh.pa.us> (raw)
In-Reply-To: <3F45BB45.80704@klaster.net>
References: <1061533501.3f45b73d6566d@webmail.t-online.de>
<3F45BB45.80704@klaster.net>
Tomasz Myrta <jasiek@klaster.net> writes:
> cast('1970-1-1' as timestamp)+cast(your_ticks || ' seconds' as interval)
> Does anyone know better way to cast it?
The above will probably give the wrong answer (off by your timezone
offset). The reference point should be zero hour GMT, but the first
cast will give zero hour local time. You should cast the reference
to timestamp with time zone (timestamptz) instead.
Also, I'd suggest using float-times-interval as a simpler and more
efficient way of forming the offset interval. So:
select 'epoch'::timestamp with time zone + your_ticks * '1 second'::interval;
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, jasiek@klaster.net, MichaelHoeller@t-online.de
Subject: Re: date calculation
In-Reply-To: <6305.1061557010@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