1
1
<!--
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 $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -2732,7 +2732,7 @@ PostgreSQL documentation
2732
2732
<row>
2733
2733
<entry><function>timeofday()</function></entry>
2734
2734
<entry><type>text</type></entry>
2735
- <entry>High-precision date and time; see also <link
2735
+ <entry>Current date and time; see <link
2736
2736
linkend="functions-datetime-current">below</link>
2737
2737
</entry>
2738
2738
<entry><literal>timeofday()</literal></entry>
@@ -3208,25 +3208,50 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
3208
3208
The following functions are available to obtain the current date and/or
3209
3209
time:
3210
3210
<synopsis>
3211
- CURRENT_TIME
3212
3211
CURRENT_DATE
3212
+ CURRENT_TIME
3213
3213
CURRENT_TIMESTAMP
3214
+ CURRENT_TIME ( <replaceable>precision</> )
3215
+ CURRENT_TIMESTAMP ( <replaceable>precision</> )
3214
3216
</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.
3218
3222
</para>
3219
3223
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
+
3220
3242
<informalexample>
3221
3243
<screen>
3222
3244
SELECT CURRENT_TIME;
3223
- <computeroutput>19:07:32 </computeroutput>
3245
+ <computeroutput>14:39:53.662522-05 </computeroutput>
3224
3246
3225
3247
SELECT CURRENT_DATE;
3226
- <computeroutput>2001-02-17 </computeroutput>
3248
+ <computeroutput>2001-12-23 </computeroutput>
3227
3249
3228
3250
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>
3230
3255
</screen>
3231
3256
</informalexample>
3232
3257
@@ -3237,9 +3262,8 @@ SELECT CURRENT_TIMESTAMP;
3237
3262
</para>
3238
3263
3239
3264
<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:
3243
3267
</para>
3244
3268
3245
3269
<informalexample>
@@ -3249,15 +3273,6 @@ SELECT timeofday();
3249
3273
</screen>
3250
3274
</informalexample>
3251
3275
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
-
3261
3276
<para>
3262
3277
It is quite important to realize that
3263
3278
<function>CURRENT_TIMESTAMP</function> and related functions all return