From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | SF Postgres <sfpug(at)postgresql(dot)org> |
Subject: | Re: epoch to timestamp |
Date: | 2003-08-20 19:09:16 |
Message-ID: | 20030820190916.GE14335@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | sfpug |
On Wed, Aug 20, 2003 at 10:51:01AM -0700, elein wrote:
> Someone tell me the easier, softer way to convert an epoch into a
> timestamp.
> This is the ugly way:
> select ('1/1/1970'::timestamp + '968190450 seconds')::timestamp;
Similar guts below...
On hackers, Tom Lane proposed a function that does this using Pl/PgSQL
like this:
CREATE OR REPLACE FUNCTION epoch_to_timestamp (FLOAT8)
RETURNS timestampz AS '
BEGIN
RETURN ''epoch''::timestamptz + $1 * ''1 second''::interval;
END;
' LANGUAGE 'plpgsql';
Despite the fact that it's (in hindsight) trivial to do, I'm still
lobbying for making this a built-in function. Any pointers on how to
do this in C & roll it into the tree?
Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
From | Date | Subject | |
---|---|---|---|
Next Message | elein | 2003-08-20 20:46:00 | Re: epoch to timestamp |
Previous Message | elein | 2003-08-20 17:51:01 | epoch to timestamp |