Search Postgresql Archives

Re: function for current date-time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux