Обсуждение: function for current date-time

Поиск
Список
Период
Сортировка

function for current date-time

От
"Harpreet Dhaliwal"
Дата:
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?

Thanks,
~Harpreet

Re: function for current date-time

От
Bricklen Anderson
Дата:
Harpreet Dhaliwal wrote:
> 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?
>
> Thanks,
> ~Harpreet

http://www.postgresql.org/docs/8.1/interactive/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

Re: function for current date-time

От
Reid Thompson
Дата:
On Mon, 2006-10-16 at 14:56 -0400, Harpreet Dhaliwal wrote:
> 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?
>
> Thanks,
> ~Harpreet

test=# select now();
              now
-------------------------------
 2006-10-16 15:03:13.174644-04
(1 row)


Re: function for current date-time

От
"A. Kretschmer"
Дата:
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

[ANN] VTD-XML 1.7 released

От
"Jimmy Zhang"
Дата:
XimpleWare released Version 1.7 of VTD-XML, the next generation XML
parser that goes beyond DOM and SAX, under GPL. VTD-XML is getting
faster, leaner, more stable and complete with this release. New features
included in this releases are:

* Additional XPath functions support
* Union Expression
* A rewritten VTDNav implementation
* Various bug fixes in VTDGen and XPath evaluation

Please visit http://vtd-xml.sf.net for the latest release.


For further reading, please refer to the following articles:
a.. Simplify XML Processing with VTD-XML
a.. Cut, Paste, Assemble and Split XML files with VTD-XML
a.. XML on a Chip
a.. Process Large XML Files with VTD-XML
a.. The performance Woe of Binary XML
a.. VTD-XML: The Next Generation XML Parser