Re: Date column that defaults to 'now'

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: siracusa(at)mindspring(dot)com
Cc: PostgreSQL general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Date column that defaults to 'now'
Date: 2004-01-05 21:18:15
Message-ID: 1073337495.25138.1379.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2004-01-05 at 21:00, John Siracusa wrote:
> How can I create a non-null date column that defaults to 'now' as computed
> at the time the row is inserted?

The default should be either CURRENT_DATE or timeofday()::DATE

The difference is that CURRENT_TIME, CURRENT_TIMESTAMP and CURRENT_DATE
remain the same within a transaction even if the time or date changes,
whereas timeofday() always returns the current clock time.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"And thou shalt love the LORD thy God with all thine
heart, and with all thy soul, and with all thy might."
Deuteronomy 6:5

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2004-01-05 21:29:45 Re: Date column that defaults to 'now'
Previous Message Roderick A. Anderson 2004-01-05 21:12:50 Re: Scripting a new db server setup