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
> 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
CREATE OR REPLACE FUNCTION epoch_to_timestamp (FLOAT8)
RETURNS timestampz AS '
RETURN ''epoch''::timestamptz + $1 * ''1 second''::interval;
' 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?
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
In response to
sfpug by date
|Next:||From: elein||Date: 2003-08-20 20:46:00|
|Subject: Re: epoch to timestamp|
|Previous:||From: elein||Date: 2003-08-20 17:51:01|
|Subject: epoch to timestamp|