Re: Trigger to convert UNIX time to timestamp without time zone.

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger to convert UNIX time to timestamp without time zone.
Date: 2014-06-06 13:39:28
Message-ID: 20140606133928.GD25470@crankycanuck.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jun 06, 2014 at 02:19:50PM +0100, Alberto Olivares wrote:
> How can I create a trigger to transform the time from UNIX to timestamp
> without time zone every time a new record is inserted into my database?

This is in the manual, section 9.8: to_timestamp(double precision)

It's always a little confusing when you go to look it up, because it's
not with the date and time functions, because it's actually a
formatting issue. (There's a cross reference, but if you don't know
this is just a formatting issue you won't know to follow the
reference.) You probably don't need a trigger, just put that in your
query.

Are you sure you want this without time zone? In my experience,
almost every time people think they want "without time zone" they
actually don't.

A

--
Andrew Sullivan
ajs(at)crankycanuck(dot)ca

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2014-06-06 13:44:24 Re: PostgreSQL 9.2.4 + CentOS 6.5 64 bit - segfault error in initdb
Previous Message Stefan Froehlich 2014-06-06 13:37:59 Re: interpret bytea output as text / double encode()