Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-04 Thread Joel Fradkin
all copies of the original message, including attachments. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew - Supernews Sent: Friday, March 04, 2005 2:15 AM To: pgsql-sql@postgresql.org Subject: Re: [SQL] definative way to place secs from epoc

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-04 Thread Tom Lane
Andrew - Supernews [EMAIL PROTECTED] writes: On 2005-03-04, Bret Hughes [EMAIL PROTECTED] wrote: (Why are you using timestamp without time zone anyway? For recording the Valid question. Because there is no reason to keep up with time zones It's a common mistake to think that just because

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-04 Thread Ken Johanson
and the fact that I want the same value from the data base that I put into it. same in which sense? The same absolute point in time? Or the same point on a calendar? Obviously if the timezone doesn't change, then the two are equivalent; but which one is your application actually looking for? (If

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-04 Thread Ken Johanson
Unix time stamps, short (int) or long res, are always supposed to GMT based, as far as I know - I never seen anything different, except maybe in homebrew software. So it should be both calendar and P.I.T. And you wouldn't need the TZ storage if the date-number and number- translation itself

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-04 Thread Andrew - Supernews
On 2005-03-04, Joel Fradkin [EMAIL PROTECTED] wrote: Just so I don't make a newb mistake I should use timestamptz not timestamp where the exact moment is important? Yes. -- Andrew, Supernews http://www.supernews.com - individual and corporate NNTP services ---(end of

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-04 Thread Bret Hughes
On Fri, 2005-03-04 at 01:35, Michael Glaesemann wrote: On Mar 4, 2005, at 14:47, Bret Hughes wrote: On Thu, 2005-03-03 at 14:58, Andrew - Supernews wrote: (Why are you using timestamp without time zone anyway? For recording the time at which an event occurred that usage is simply

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-03 Thread Andrew - Supernews
On 2005-03-03, Bret Hughes [EMAIL PROTECTED] wrote: a RFE would be to let to_timestamp be to a timezone without time zone and have a to_timestamptz do the time zone thing. Seems more consistent and would give me the functionality I am looking for :) Unix epoch times correspond to timestamp

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-03 Thread Bret Hughes
On Thu, 2005-03-03 at 14:58, Andrew - Supernews wrote: On 2005-03-03, Bret Hughes [EMAIL PROTECTED] wrote: a RFE would be to let to_timestamp be to a timezone without time zone and have a to_timestamptz do the time zone thing. Seems more consistent and would give me the functionality I am

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-03 Thread Andrew - Supernews
On 2005-03-04, Bret Hughes [EMAIL PROTECTED] wrote: Unix epoch times correspond to timestamp _with_ time zone. (Why are you using timestamp without time zone anyway? For recording the time at which an event occurred that usage is simply wrong - in fact I can't see any situation in which a

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-03 Thread Michael Glaesemann
On Mar 4, 2005, at 14:47, Bret Hughes wrote: On Thu, 2005-03-03 at 14:58, Andrew - Supernews wrote: (Why are you using timestamp without time zone anyway? For recording the time at which an event occurred that usage is simply wrong - in fact I can't see any situation in which a Unix epoch time

[SQL] definative way to place secs from epoc into timestamp column

2005-03-02 Thread Bret Hughes
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. I am adding functionality to a php app that does a fair amount of work with time and am currently using

Re: [SQL] definative way to place secs from epoc into timestamp column

2005-03-02 Thread Tom Lane
Bret Hughes [EMAIL PROTECTED] 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:

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-02 Thread Bret Hughes
On Wed, 2005-03-02 at 13:52, Tom Lane wrote: Bret Hughes [EMAIL PROTECTED] 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

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-02 Thread Tom Lane
Bret Hughes [EMAIL PROTECTED] writes: 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

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-02 Thread Bret Hughes
On Wed, 2005-03-02 at 14:26, Tom Lane wrote: Bret Hughes [EMAIL PROTECTED] writes: 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' +

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-02 Thread Tom Lane
Bret Hughes [EMAIL PROTECTED] writes: create function int2ts(integer) returns timestamp as ' SELECT ( TIMESTAMP WITH TIME ZONE \'epoch\' + $1 * INTERVAL \'1 second\')::timestamp without time zone; ' language sql; create function ts2int(timestamp without time zone) returns int as ' select

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-02 Thread Michael Glaesemann
On Mar 3, 2005, at 14:42, Bret Hughes wrote: also my first two pgsql functions :) cat ts2int.sql FWIW, there's a patch in the queue for 8.1 that adds a to_timestamp function that converts between Unix epoch and timestamp with time zone. http://momjian.postgresql.org/cgi-bin/pgpatches2 Doesn't

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-02 Thread Bret Hughes
On Thu, 2005-03-03 at 00:25, Tom Lane wrote: Bret Hughes [EMAIL PROTECTED] writes: create function int2ts(integer) returns timestamp as ' SELECT ( TIMESTAMP WITH TIME ZONE \'epoch\' + $1 * INTERVAL \'1 second\')::timestamp without time zone; ' language sql; create function

Re: [SQL] definative way to place secs from epoc into timestamp

2005-03-02 Thread Bret Hughes
On Thu, 2005-03-03 at 00:41, Michael Glaesemann wrote: On Mar 3, 2005, at 14:42, Bret Hughes wrote: also my first two pgsql functions :) cat ts2int.sql FWIW, there's a patch in the queue for 8.1 that adds a to_timestamp function that converts between Unix epoch and timestamp with