Skip to content

Commit ce4d01d

Browse files
committed
Update description of CURRENT_TIMESTAMP and friends.
1 parent 78ec1cb commit ce4d01d

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

doc/src/sgml/func.sgml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.87 2001/12/01 04:19:20 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.88 2001/12/23 20:22:49 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -2732,7 +2732,7 @@ PostgreSQL documentation
27322732
<row>
27332733
<entry><function>timeofday()</function></entry>
27342734
<entry><type>text</type></entry>
2735-
<entry>High-precision date and time; see also <link
2735+
<entry>Current date and time; see <link
27362736
linkend="functions-datetime-current">below</link>
27372737
</entry>
27382738
<entry><literal>timeofday()</literal></entry>
@@ -3208,25 +3208,50 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
32083208
The following functions are available to obtain the current date and/or
32093209
time:
32103210
<synopsis>
3211-
CURRENT_TIME
32123211
CURRENT_DATE
3212+
CURRENT_TIME
32133213
CURRENT_TIMESTAMP
3214+
CURRENT_TIME ( <replaceable>precision</> )
3215+
CURRENT_TIMESTAMP ( <replaceable>precision</> )
32143216
</synopsis>
3215-
Note that because of the requirements of the
3216-
<acronym>SQL</acronym> standard, these functions must not be
3217-
called with trailing parentheses.
3217+
<function>CURRENT_TIME</function> and
3218+
<function>CURRENT_TIMESTAMP</function> can optionally be given
3219+
a precision parameter, which causes the result to be rounded
3220+
to that many fractional digits. Without a precision parameter,
3221+
the result is given to full available precision.
32183222
</para>
32193223

3224+
<note>
3225+
<para>
3226+
Prior to <productname>PostgreSQL</> 7.2, the precision parameters
3227+
were unimplemented, and the result was always given in integer
3228+
seconds.
3229+
</para>
3230+
</note>
3231+
3232+
<note>
3233+
<para>
3234+
The <acronym>SQL99</acronym> standard requires these functions to
3235+
be written without any parentheses, unless a precision parameter
3236+
is given. As of <productname>PostgreSQL</> 7.2, an empty pair of
3237+
parentheses can be written, but this is deprecated and may be
3238+
removed in a future release.
3239+
</para>
3240+
</note>
3241+
32203242
<informalexample>
32213243
<screen>
32223244
SELECT CURRENT_TIME;
3223-
<computeroutput>19:07:32</computeroutput>
3245+
<computeroutput>14:39:53.662522-05</computeroutput>
32243246

32253247
SELECT CURRENT_DATE;
3226-
<computeroutput>2001-02-17</computeroutput>
3248+
<computeroutput>2001-12-23</computeroutput>
32273249

32283250
SELECT CURRENT_TIMESTAMP;
3229-
<computeroutput>2001-02-17 19:07:32-05</computeroutput>
3251+
<computeroutput>2001-12-23 14:39:53.662522-05</computeroutput>
3252+
3253+
SELECT CURRENT_TIMESTAMP(2);
3254+
<computeroutput>2001-12-23 14:39:53.66-05</computeroutput>
32303255
</screen>
32313256
</informalexample>
32323257

@@ -3237,9 +3262,8 @@ SELECT CURRENT_TIMESTAMP;
32373262
</para>
32383263

32393264
<para>
3240-
There is also <function>timeofday()</function>, which returns current
3241-
time to higher precision than the <function>CURRENT_TIMESTAMP</function>
3242-
family does:
3265+
There is also <function>timeofday()</function>, which for historical
3266+
reasons returns a text string rather than a <type>timestamp</type> value:
32433267
</para>
32443268

32453269
<informalexample>
@@ -3249,15 +3273,6 @@ SELECT timeofday();
32493273
</screen>
32503274
</informalexample>
32513275

3252-
<para>
3253-
<function>timeofday()</function> uses the operating system call
3254-
<function>gettimeofday(2)</function>, which may have resolution as
3255-
good as microseconds (depending on your platform); the other functions
3256-
rely on <function>time(2)</function> which is restricted to one-second
3257-
resolution. For historical reasons, <function>timeofday()</function>
3258-
returns its result as a text string rather than a <type>timestamp</type> value.
3259-
</para>
3260-
32613276
<para>
32623277
It is quite important to realize that
32633278
<function>CURRENT_TIMESTAMP</function> and related functions all return

0 commit comments

Comments
 (0)