David Fetter <david@fetter.org> writes:
> [code]
Seems pretty messy. I believe the standard way of doing this is
regression=# create function epoch_to_timestamp(float8) returns timestamptz as '
regression'# begin
regression'# return ''epoch''::timestamptz + $1 * ''1 second''::interval;
regression'# end' language plpgsql strict immutable;
CREATE FUNCTION
regression=# select now(), extract(epoch from now()); now | date_part
-------------------------------+-----------------2003-08-16 08:43:16.925501-04 | 1061037796.9255
(1 row)
regression=# select epoch_to_timestamp(1061037796.9255); epoch_to_timestamp
-----------------------------2003-08-16 08:43:16.9255-04
(1 row)
regards, tom lane