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

From Michael Glaesemann
Subject Re: Date column that defaults to 'now'
Date
Msg-id 47FD71B4-3FC6-11D8-BA4F-000A95C88220@myrealbox.com
Whole thread Raw
In response to Date column that defaults to 'now'  (John Siracusa <siracusa@mindspring.com>)
Responses Re: Date column that defaults to 'now'  (John Siracusa <siracusa@mindspring.com>)
List pgsql-general
Hi John!

On Jan 5, 2004, at 3:00 PM, 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?

How about this?

test=# create table johns (comment text not null,this_time timestamp
not null default now(), this_date date not null default now());
CREATE TABLE
test=# insert into johns (comment) values ('Ars Technica rocks!');
INSERT 1196312 1
test=# select * from johns;
        comment       |         this_time          | this_date
---------------------+----------------------------+------------
  Ars Technica rocks! | 2004-01-05 15:25:52.501707 | 2004-01-05
(1 row)

(If you're not the John Siracusa who writes for Ars Technica, the
sentiment still holds. :) )

Regards,

Michael Glaesemann
grzm myrealbox com


pgsql-general by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: Date column that defaults to 'now'
Next
From: John Siracusa
Date:
Subject: Re: Date column that defaults to 'now'