Re: Datetime operators (was: Re: [SQL] Another Date question)

From: <kaiq(at)realtyideas(dot)com>
To: Andy Lewis <alewis(at)roundnoon(dot)com>
Cc: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>, Karel Zak - Zakkr <zakkr(at)zf(dot)jcu(dot)cz>, pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>, pgsql-sql <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: Datetime operators (was: Re: [SQL] Another Date question)
Date: 1999-12-03 20:48:09
Message-ID: Pine.LNX.4.10.9912031439170.14529-100000@picasso.realtyideas.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

I know, thanks to you, but why? It supposes to work. seems things within
default's parenthesis are different for no reason.

I mean,
insert into mymy values( now() + '60 days'::timespan );
works fine. usually the more strict one (diligitantly casted one)
always works.

I feel pain about it :-) because that was what I tried, and then, since it
did not work, I assumed "default" did not accept expressions.

On Fri, 3 Dec 1999, Andy Lewis wrote:

> Remove the ::timespan and it will.
>
> Andy
>
> On Fri, 3 Dec 1999 kaiq(at)realtyideas(dot)com wrote:
>
> > why
> >
> > create table mymy (mydate datetime default (now() + '60 days'::timespan ));
> >
> > does not work?
> >
> > On Fri, 3 Dec 1999, Thomas Lockhart wrote:
> >
> > > > > I'd like to create a table with a datetime field that defaults to +60
> > > > > days.
> > > > > mydate datetime default 'now() +(at)60 days',
> > > > > ...
> > > > Where is a problem?
> > >
> > > You have enclosed your default values into a large string, rather than
> > > letting them be evaluated as an expression:
> > >
> > > mydate datetime default (now() + '60 days')
> > >
> > > where the outer parens are optional.
> > >
> > > > datetime + '10 day' or
> > > > datetime + '2 year' ..etc.
> > > > But I'm not sure what is better or exists it in other SQL.
> > >
> > > afaik this is the simplest and most direct way to do it. Note that you
> > > can include other timespan fields in the constant:
> > >
> > > mydate datetime default (now() + '60 days 10 hours')
> > >
> > > HTH
> > >
> > > - Thomas
> > >
> > > --
> > > Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
> > > South Pasadena, California
> > >
> > > ************
> > >
> >
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message kaiq 1999-12-03 21:01:51 Re: Datetime operators (was: Re: [SQL] Another Date question)
Previous Message Thomas Lockhart 1999-12-03 20:15:10 Re: emacs question

Browse pgsql-sql by date

  From Date Subject
Next Message kaiq 1999-12-03 21:01:51 Re: Datetime operators (was: Re: [SQL] Another Date question)
Previous Message Thomas Lockhart 1999-12-03 20:06:13 Re: Datetime operators (was: Re: [SQL] Another Date question)