[PostgreSQL] Umwandlung Unix-Timestamp zu normalem Datum

Ich habe für unser ZABOS-System gerade eine kleine PostgreSQL-Funktion geschrieben, die mir einen Unix-Timestamp in ein lesbares Datum umwandelt.

Hier der Code:

CREATE OR REPLACE FUNCTION "public"."makedisplaydate" (_timestamp integer) RETURNS varchar AS
$body$
DECLARE
  rDate varchar;
BEGIN
  SELECT to_char('epoch'::timestamptz + (_timestamp) * '1 sec'::interval, 'YYYY-MM-DD HH12:MI:SS (Dy)') INTO rDate;
  RETURN rDate;
END;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>