pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
timestamps
2+ messages / 2 participants
[nested] [flat]

* timestamps
@ 1999-11-03 02:51  David Rugge <davidrugge@mindspring.com>
  0 siblings, 1 reply; 2+ messages in thread

From: David Rugge @ 1999-11-03 02:51 UTC (permalink / raw)
  To: pgsql-sql

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!

What can I do to make a timestamp that is the date the row was inserted into
the table?

--
David Rugge

http://www.mindspring.com/~davidrugge/index.html



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] timestamps
@ 1999-11-03 05:48  Tom Lane <tgl@sss.pgh.pa.us>
  parent: David Rugge <davidrugge@mindspring.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 1999-11-03 05:48 UTC (permalink / raw)
  To: davidrugge@mindspring.com; +Cc: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1999-11-03 05:48 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-11-03 02:51 timestamps David Rugge <davidrugge@mindspring.com>
1999-11-03 05:48 ` Tom Lane <tgl@sss.pgh.pa.us>

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