Re: [SQL] Re: Date Time Functions - ANSI SQL ?

2001-08-05 Thread Josh Berkus
Gonzo, > > I'm trying to find a pgSQL source that documents the Non-Standard > > pgSQL stuff, the stuff that will break when attempting to execute > > against mySQL/Oracle/MSSQLServer etc... Almost anything you port will break MS SQL Server (7.0 and 6.5, anyway). SQL Server is so far off the ANS

[SQL] Re: Date Time Functions - ANSI SQL ?

2001-08-05 Thread Peter Eisentraut
Gonzo Rock writes: > I'm trying to find a pgSQL source that documents the Non-Standard > pgSQL stuff, the stuff that will break when attempting to execute > against mySQL/Oracle/MSSQLServer etc... While it would be an appreciated effort to create such a document (and we already try to document s

[SQL] Re: Date manipulation

2001-06-05 Thread Reinoud van Leeuwen
On Thu, 31 May 2001 17:24:54 + (UTC), [EMAIL PROTECTED] (Mark) wrote: > >How does one perform date manipulation within SQL? For example, SQL >Server has a dateadd() function that takes a date part, scalar, and the >date to manipulate. > >I have a query that determines the number of days that

[SQL] RE: DATE

2001-01-23 Thread Michael Davis
Select now() + 7; -Original Message- From: john whale [SMTP:[EMAIL PROTECTED]] Sent: Monday, January 22, 2001 10:30 AM To: '[EMAIL PROTECTED]' Subject:DATE PLEASE ADVISE HOW I SHOULD ALTER THE COMMAND: <$NOW;DD;> TO GIVE ME A DATE THAT IS X DAYS FORWARD ie: I

Re: [SQL] Re: Date of creation and of change

2000-08-25 Thread hlefebvre
Andreas Tille wrote: > > On Fri, 25 Aug 2000, Tom Lane wrote: > > > I think you are getting burnt by premature constant folding --- see > > nearby discussion of how to define a column default that gives the > > time of insertion. You need to write this as > > NEW.ChangedAt := now(); > >

[SQL] Re: Date of creation and of change

2000-08-25 Thread Andreas Tille
On Fri, 25 Aug 2000, hlefebvre wrote: > Tom Lane wrote: > > NEW.ChangedAt := now(); > > to prevent the system from reducing timestamp('now') to a constant > > when the function is first executed. > > > > regards, tom lane > yep you're right : You both are comple

Re: [SQL] Re: Date of creation and of change

2000-08-25 Thread hlefebvre
Tom Lane wrote: > > Andreas Tille <[EMAIL PROTECTED]> writes: > >> NEW.ChangedAt := timestamp(''now''); > > > This avoids the error message, but doesn't have any effect to the value > > of ChangedAt. It just remains the same as CreatedAt :-(. > > I think you are getting burnt by premature co

[SQL] Re: Date of creation and of change

2000-08-25 Thread Andreas Tille
On Fri, 25 Aug 2000, Tom Lane wrote: > I think you are getting burnt by premature constant folding --- see > nearby discussion of how to define a column default that gives the > time of insertion. You need to write this as > NEW.ChangedAt := now(); > to prevent the system from reducing tim

Re: [SQL] Re: Date of creation and of change

2000-08-25 Thread Tom Lane
Andreas Tille <[EMAIL PROTECTED]> writes: >> NEW.ChangedAt := timestamp(''now''); > This avoids the error message, but doesn't have any effect to the value > of ChangedAt. It just remains the same as CreatedAt :-(. I think you are getting burnt by premature constant folding --- see nearby discu

Re: [SQL] Re: Date of creation and of change

2000-08-25 Thread hlefebvre
Andreas Tille wrote: > > On Fri, 25 Aug 2000, hlefebvre wrote: > > > No I suppose that the problem is the identifier "changedat" is unknown. > > > > You must probably prefix it : NEW.changedat > > > > CREATE FUNCTION changed_at_timestamp() RETURNS OPAQUE AS ' > > BEGIN > > NEW.C

[SQL] Re: Date of creation and of change

2000-08-25 Thread Andreas Tille
On Fri, 25 Aug 2000, hlefebvre wrote: > No I suppose that the problem is the identifier "changedat" is unknown. > > You must probably prefix it : NEW.changedat > > CREATE FUNCTION changed_at_timestamp() RETURNS OPAQUE AS ' > BEGIN > NEW.ChangedAt := timestamp(''now''); >

Re: [SQL] Re: Date of creation and of change

2000-08-25 Thread hlefebvre
Andreas Tille wrote: > > On Wed, 23 Aug 2000, hlefebvre wrote: > > > Yes. The keywords NEW / OLD are available only in triggers > > see > > http://www.postgresql.org/users-lounge/docs/7.0/user/c40874113.htm#AEN4286 > Well, I believe that, but > > CREATE FUNCTION changed_at_timestamp() RETURNS

[SQL] Re: Date of creation and of change

2000-08-25 Thread Andreas Tille
On Wed, 23 Aug 2000, hlefebvre wrote: > Yes. The keywords NEW / OLD are available only in triggers > see > http://www.postgresql.org/users-lounge/docs/7.0/user/c40874113.htm#AEN4286 Well, I believe that, but CREATE FUNCTION changed_at_timestamp() RETURNS OPAQUE AS ' BEGIN ChangedAt

Re: [SQL] Re: Date of creation and of change

2000-08-23 Thread Tom Lane
Andreas Tille <[EMAIL PROTECTED]> writes: > On Wed, 23 Aug 2000, hlefebvre wrote: >> create table mytable( CreateDate timestamp default timestamp('now'), >> ); > I've done a pg_dump and there this line was transformed to: > "createdat" timestamp DEFAULT '23.08.2000 15:35:16.00 CEST'::"t

Re: [SQL] Re: Date of creation and of change

2000-08-23 Thread hlefebvre
Andreas Tille wrote: > I tried: > > web=# CREATE FUNCTION changed_at_timestamp () RETURNS OPAQUE AS ' > web'# BEGIN > web'# ChangeDate := timestamp(''now''); > web'# RETURN NEW; > web'# END; > web'# ' LANGUAGE 'plpgsql'; > CREATE > web=# select changed_at_timestamp () ;

[SQL] Re: Date of creation and of change

2000-08-23 Thread Andreas Tille
On Wed, 23 Aug 2000, hlefebvre wrote: > create table mytable( CreateDate timestamp default timestamp('now'), > ); I've done a pg_dump and there this line was transformed to: "createdat" timestamp DEFAULT '23.08.2000 15:35:16.00 CEST'::"timestamp", I'm afraid if I ever should use this

[SQL] Re: Date of creation and of change

2000-08-23 Thread Andreas Tille
On Wed, 23 Aug 2000, hlefebvre wrote: > create table mytable( CreateDate timestamp default timestamp('now'), > ); Thanks, this works. > CREATE FUNCTION myt_stamp () RETURNS OPAQUE AS > BEGIN > ChangeDate := timestamp(''now''); > RETURN NEW; > END; > ' LANGUAGE 'pl