From ce4d01d96b7e41cf61b8ee3ab4018e15e01dc872 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 23 Dec 2001 20:22:49 +0000 Subject: [PATCH] Update description of CURRENT_TIMESTAMP and friends. --- doc/src/sgml/func.sgml | 57 ++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 5e55381bf6..c9af36d550 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,5 +1,5 @@ @@ -2732,7 +2732,7 @@ PostgreSQL documentation timeofday() text - High-precision date and time; see also Current date and time; see below timeofday() @@ -3208,25 +3208,50 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40'); The following functions are available to obtain the current date and/or time: -CURRENT_TIME CURRENT_DATE +CURRENT_TIME CURRENT_TIMESTAMP +CURRENT_TIME ( precision ) +CURRENT_TIMESTAMP ( precision ) - Note that because of the requirements of the - SQL standard, these functions must not be - called with trailing parentheses. + CURRENT_TIME and + CURRENT_TIMESTAMP can optionally be given + a precision parameter, which causes the result to be rounded + to that many fractional digits. Without a precision parameter, + the result is given to full available precision. + + + Prior to PostgreSQL 7.2, the precision parameters + were unimplemented, and the result was always given in integer + seconds. + + + + + + The SQL99 standard requires these functions to + be written without any parentheses, unless a precision parameter + is given. As of PostgreSQL 7.2, an empty pair of + parentheses can be written, but this is deprecated and may be + removed in a future release. + + + SELECT CURRENT_TIME; -19:07:32 +14:39:53.662522-05 SELECT CURRENT_DATE; -2001-02-17 +2001-12-23 SELECT CURRENT_TIMESTAMP; -2001-02-17 19:07:32-05 +2001-12-23 14:39:53.662522-05 + +SELECT CURRENT_TIMESTAMP(2); +2001-12-23 14:39:53.66-05 @@ -3237,9 +3262,8 @@ SELECT CURRENT_TIMESTAMP; - There is also timeofday(), which returns current - time to higher precision than the CURRENT_TIMESTAMP - family does: + There is also timeofday(), which for historical + reasons returns a text string rather than a timestamp value: @@ -3249,15 +3273,6 @@ SELECT timeofday(); - - timeofday() uses the operating system call - gettimeofday(2), which may have resolution as - good as microseconds (depending on your platform); the other functions - rely on time(2) which is restricted to one-second - resolution. For historical reasons, timeofday() - returns its result as a text string rather than a timestamp value. - - It is quite important to realize that CURRENT_TIMESTAMP and related functions all return -- 2.40.0