Re: Date column that defaults to 'now' - Mailing list pgsql-general

From Oliver Elphick
Subject Re: Date column that defaults to 'now'
Date
Msg-id 1073337495.25138.1379.camel@linda.lfix.co.uk
Whole thread Raw
In response to Date column that defaults to 'now'  (John Siracusa <siracusa@mindspring.com>)
List 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.Elphick@lfix.co.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


pgsql-general by date:

Previous
From: "Roderick A. Anderson"
Date:
Subject: Re: Scripting a new db server setup
Next
From: Michael Glaesemann
Date:
Subject: Re: Date column that defaults to 'now'