From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | New function: epoch_to_timestamp... |
Date: | 2003-08-14 20:46:31 |
Message-ID: | 20030814204631.GG14335@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
From | Date | Subject | |
---|---|---|---|
Next Message | Carlos Guzman Alvarez | 2003-08-14 20:53:46 | Re: SSL Connection / Windows + Cygwin + PostgreSQL 7.4 |
Previous Message | Tom Lane | 2003-08-14 20:05:10 | Re: SSL Connection / Windows + Cygwin + PostgreSQL 7.4 Beta 1 question |