Commit ce4d01d9 authored by Tom Lane's avatar Tom Lane

Update description of CURRENT_TIMESTAMP and friends.

parent 78ec1cb0
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.87 2001/12/01 04:19:20 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.88 2001/12/23 20:22:49 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -2732,7 +2732,7 @@ PostgreSQL documentation ...@@ -2732,7 +2732,7 @@ PostgreSQL documentation
<row> <row>
<entry><function>timeofday()</function></entry> <entry><function>timeofday()</function></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry>High-precision date and time; see also <link <entry>Current date and time; see <link
linkend="functions-datetime-current">below</link> linkend="functions-datetime-current">below</link>
</entry> </entry>
<entry><literal>timeofday()</literal></entry> <entry><literal>timeofday()</literal></entry>
...@@ -3208,25 +3208,50 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40'); ...@@ -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 The following functions are available to obtain the current date and/or
time: time:
<synopsis> <synopsis>
CURRENT_TIME
CURRENT_DATE CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_TIMESTAMP
CURRENT_TIME ( <replaceable>precision</> )
CURRENT_TIMESTAMP ( <replaceable>precision</> )
</synopsis> </synopsis>
Note that because of the requirements of the <function>CURRENT_TIME</function> and
<acronym>SQL</acronym> standard, these functions must not be <function>CURRENT_TIMESTAMP</function> can optionally be given
called with trailing parentheses. 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.
</para> </para>
<note>
<para>
Prior to <productname>PostgreSQL</> 7.2, the precision parameters
were unimplemented, and the result was always given in integer
seconds.
</para>
</note>
<note>
<para>
The <acronym>SQL99</acronym> standard requires these functions to
be written without any parentheses, unless a precision parameter
is given. As of <productname>PostgreSQL</> 7.2, an empty pair of
parentheses can be written, but this is deprecated and may be
removed in a future release.
</para>
</note>
<informalexample> <informalexample>
<screen> <screen>
SELECT CURRENT_TIME; SELECT CURRENT_TIME;
<computeroutput>19:07:32</computeroutput> <computeroutput>14:39:53.662522-05</computeroutput>
SELECT CURRENT_DATE; SELECT CURRENT_DATE;
<computeroutput>2001-02-17</computeroutput> <computeroutput>2001-12-23</computeroutput>
SELECT CURRENT_TIMESTAMP; SELECT CURRENT_TIMESTAMP;
<computeroutput>2001-02-17 19:07:32-05</computeroutput> <computeroutput>2001-12-23 14:39:53.662522-05</computeroutput>
SELECT CURRENT_TIMESTAMP(2);
<computeroutput>2001-12-23 14:39:53.66-05</computeroutput>
</screen> </screen>
</informalexample> </informalexample>
...@@ -3237,9 +3262,8 @@ SELECT CURRENT_TIMESTAMP; ...@@ -3237,9 +3262,8 @@ SELECT CURRENT_TIMESTAMP;
</para> </para>
<para> <para>
There is also <function>timeofday()</function>, which returns current There is also <function>timeofday()</function>, which for historical
time to higher precision than the <function>CURRENT_TIMESTAMP</function> reasons returns a text string rather than a <type>timestamp</type> value:
family does:
</para> </para>
<informalexample> <informalexample>
...@@ -3249,15 +3273,6 @@ SELECT timeofday(); ...@@ -3249,15 +3273,6 @@ SELECT timeofday();
</screen> </screen>
</informalexample> </informalexample>
<para>
<function>timeofday()</function> uses the operating system call
<function>gettimeofday(2)</function>, which may have resolution as
good as microseconds (depending on your platform); the other functions
rely on <function>time(2)</function> which is restricted to one-second
resolution. For historical reasons, <function>timeofday()</function>
returns its result as a text string rather than a <type>timestamp</type> value.
</para>
<para> <para>
It is quite important to realize that It is quite important to realize that
<function>CURRENT_TIMESTAMP</function> and related functions all return <function>CURRENT_TIMESTAMP</function> and related functions all return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment