From: Thomas Lockhart <lockhart@alumni.caltech.edu>
To: Karel Zak - Zakkr <zakkr@zf.jcu.cz>
Cc: Andy Lewis <alewis@roundnoon.com>
Cc: pgsql-hackers <pgsql-hackers@postgreSQL.org>
Cc: pgsql-sql <pgsql-sql@postgreSQL.org>
Subject: Re: Datetime operators (was: Re: [SQL] Another Date question)
Date: Fri, 03 Dec 1999 15:48:35 +0000
Message-ID: <3847E653.AAF97645@alumni.caltech.edu> (raw)
References: <Pine.LNX.3.96.991203121007.14172A-100000@ara.zf.jcu.cz>
> > I'd like to create a table with a datetime field that defaults to +60
> > days.
> > mydate datetime default 'now() +@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@alumni.caltech.edu
South Pasadena, California
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: lockhart@alumni.caltech.edu, zakkr@zf.jcu.cz, alewis@roundnoon.com, pgsql-hackers@postgreSQL.org
Subject: Re: Datetime operators (was: Re: [SQL] Another Date question)
In-Reply-To: <3847E653.AAF97645@alumni.caltech.edu>
References: <Pine.LNX.3.96.991203121007.14172A-100000@ara.zf.jcu.cz> <3847E653.AAF97645@alumni.caltech.edu>
* 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