Skip site navigation (1) Skip section navigation (2)

Re: Unixtime (epoch) into timestamp?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ericson Smith <eric(at)did-it(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unixtime (epoch) into timestamp?
Date: 2002-09-27 02:44:33
Message-ID: 20204.1033094673@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Ericson Smith <eric(at)did-it(dot)com> writes:
> Just added this handy little function to our catalog based on that
> answer:

> CREATE FUNCTION "fn_date"(int4) RETURNS timestamp with time zone AS
> 'DECLARE
> my_epoch ALIAS FOR $1;
> my_ret timestamp;
> BEGIN
>    SELECT INTO my_ret "timestamp"(my_epoch);
>    RETURN my_ret;
> END;' LANGUAGE 'plpgsql'; 

Better make that
     SELECT INTO my_ret "timestamptz"(my_epoch);
else it will break in 7.3 --- "timestamp" is going to start meaning
"timestamp without time zone", per SQL spec.  Likewise my_ret had
better be explicitly declared timestamptz or timestamp with time zone.
Otherwise looks good.

			regards, tom lane

In response to

pgsql-general by date

Next:From: Tom LaneDate: 2002-09-27 02:52:17
Subject: Re: get date in binary number format
Previous:From: Scott ChapmanDate: 2002-09-27 02:40:37
Subject: Re: SQL subquery to supply table name?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group