From: Tom Lane <tgl@sss.pgh.pa.us>
To: davidrugge@mindspring.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] timestamps
Date: Wed, 03 Nov 1999 00:48:26 -0500
Message-ID: <18776.941608106@sss.pgh.pa.us> (raw)
In-Reply-To: <99110221560802.00836@joplin>
David Rugge <davidrugge@mindspring.com> writes:
> I created a table using this statement:
> create table timestamptest (creation_date timestamp default text 'now')
> But I get the creation date of the table instead of the date of the
> transaction. This is the format suggested in the manual to workaround the
> default value being set at table creation, but it doesn't work!
Try "default now()".
The documentation recommending "default text 'now'" is bogus, IMHO.
That method depends on a particular set of interacting behaviors in the
parser and the table-default-creation code, and at least some of those
behaviors were arguably bugs. They were also data-type-dependent ---
I believe "default text 'now'" does work in 6.5.* for a DATETIME column,
but not for a TIMESTAMP column, because of slight differences in the
sets of available operators for the two datatypes.
FYI, any of these variants should give the result you want in future
releases. But now() is the only one that I think can be counted on
to work in current and obsolete Postgres versions too.
regards, tom lane
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: tgl@sss.pgh.pa.us, davidrugge@mindspring.com
Subject: Re: [SQL] timestamps
In-Reply-To: <18776.941608106@sss.pgh.pa.us>
References: <99110221560802.00836@joplin> <18776.941608106@sss.pgh.pa.us>
* 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