You can actually kinda hack this by going:
SELECT 41235125::abstime::timestamp;
Where 41235125 is a unix epoch.
Cheers,
Chris
----- Original Message -----
From: "David Fetter" <david@fetter.org>
To: "PG Hackers" <pgsql-hackers@postgresql.org>
Sent: Friday, August 15, 2003 4:46 AM
Subject: [HACKERS] New function: epoch_to_timestamp...
> Kind people,
>
> After discussing this w/Josh yesterday, I'd like to propose a new
> function for date_time. Here's the Pl/PgSQL version, warts 'n' all.
>
> CREATE OR REPLACE FUNCTION epoch_to_timestamp (INTEGER)
> RETURNS TIMESTAMP AS '
> DECLARE
> the_sql TEXT;
> the_record RECORD;
> the_time TIMESTAMP;
> BEGIN
> the_sql := ''SELECT ''''January 1 1970''''::timestamp + ''''''
> || $1
> || '' seconds''''::interval AS "foo"'';
> FOR the_record IN EXECUTE the_sql LOOP
> the_time := the_record.foo;
> END LOOP;
> RETURN the_time;
> END;
> ' LANGUAGE 'plpgsql';
>
> My C skills (Hello, world!) aren't up to doing it that way, although
> that's probably The Right Thing(TM). Is there a reasonable way to add
> an optional param or two to mark time zones, or should that just the
> application programmer's hassle?
>
> TIA for any feedback :)
>
> Cheers,
> D
> --
> David Fetter david@fetter.org http://fetter.org/
> phone: +1 510 893 6100 cell: +1 415 235 3778
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>