From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Fetter <david(at)fetter(dot)org> |
Cc: | PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: New function: epoch_to_timestamp... |
Date: | 2003-08-16 12:44:36 |
Message-ID: | 24487.1061037876@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Fetter <david(at)fetter(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | ivan | 2003-08-16 15:13:12 | CREATE TYPE |
Previous Message | Tom Lane | 2003-08-16 12:18:19 | Re: full path infrastructure for DT_SONAME? |