From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: function for current date-time |
Date: | 2006-10-16 19:17:16 |
Message-ID: | 20061016191715.GA12075@a-kretschmer.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
am Mon, dem 16.10.2006, um 14:56:27 -0400 mailte Harpreet Dhaliwal folgendes:
> Hi,
> I have a timestamp field in my table and want to set a default value of current
> date/time for it.
> What should i enter as its default value? is there any function like now() in
> postgres?
Yes, now() ;-)
test=# create table foo (id int, ts timestamp default now());
CREATE TABLE
test=# insert into foo (id, ts) values (1, default);
INSERT 0 1
test=# select * from foo;
id | ts
----+---------------------------
1 | 2006-10-16 21:18:15.75039
(1 row)
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
From | Date | Subject | |
---|---|---|---|
Next Message | George Pavlov | 2006-10-16 19:33:35 | datatype preceded by underscore creates array |
Previous Message | Carlos H. Reimer | 2006-10-16 19:14:24 | RES: RES: Dates rejected |