From: Bret Hughes <bhughes@elevating.com>
To: postgresql sql list <pgsql-sql@postgresql.org>
Subject: Re: definative way to place secs from epoc into timestamp
Date: 02 Mar 2005 14:07:46 -0600
Message-ID: <1109794066.27857.100.camel@bretsony> (raw)
In-Reply-To: <13089.1109793126@sss.pgh.pa.us>
References: <1109780719.28180.86.camel@bretsony>
<13089.1109793126@sss.pgh.pa.us>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bhughes@elevating.com
Subject: Re: definative way to place secs from epoc into timestamp
In-Reply-To: <1109794066.27857.100.camel@bretsony>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox