Re: definative way to place secs from epoc into timestamp - Mailing list pgsql-sql

From Bret Hughes
Subject Re: definative way to place secs from epoc into timestamp
Date
Msg-id 1109794066.27857.100.camel@bretsony
Whole thread Raw
In response to Re: definative way to place secs from epoc into timestamp column  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: definative way to place secs from epoc into timestamp
List pgsql-sql
On Wed, 2005-03-02 at 13:52, Tom Lane wrote:
> Bret Hughes <bhughes@elevating.com> writes:
> > I give up.  I have STFW and STFM and still do not feel like I have a
> > good way to update/insert into a timestamp w/o TZ column with an integer
> > representing seconds from epoch.
> 
> The docs say:
> 
>   Here is how you can convert an epoch value back to a time stamp: 
> 
>      SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 982384720 * INTERVAL '1 second';
> 
> If you want a timestamp w/o time zone then the right thing depends on
> what you think the reference epoch is.  If you do
> 
>      SELECT TIMESTAMP WITHOUT TIME ZONE 'epoch' + 982384720 * INTERVAL '1 second';
> 
> then what you will get is the correct equivalent of the Unix timestamp
> in GMT time.  If you do the first calculation and then cast to timestamp
> w/o time zone then what you will get is a correct equivalent in your
> TimeZone setting.  For instance




Thanks for the feed back tom  I say that but I could not believe that I
have to jump through all those hoops on an insert or update

update mytable set (lasttime =(SELECT TIMESTAMP WITH TIME ZONE 'epoch' +
982384720 * INTERVAL '1 second') )

is this what you are saying I need to do?

also, what is happening with abstime(982384720)?  this works as expected
(by me ).  Is this a bad idea?  I can't believe that all the complicated
string manipulation stuff is there but I have to run a subselect to
insert a numeric value that I suspect is close to how it is stored
anyway.  Of course the last part is a WAG.


Bret




pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: definative way to place secs from epoc into timestamp column
Next
From: Tom Lane
Date:
Subject: Re: definative way to place secs from epoc into timestamp