Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 624fd9e

Browse files
committed
Doc: spell out comparison behaviors for the date/time types.
The behavior of cross-type comparisons among date/time data types was not really explained anywhere. You could probably infer it if you recognized the applicability of comments elsewhere about datatype conversions, but it seems worthy of explicit documentation. Per bug #16797 from Dana Burd. Discussion: https://postgr.es/m/16797-f264b0b980b53b8b@postgresql.org
1 parent 861e967 commit 624fd9e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

doc/src/sgml/func.sgml

+18-2
Original file line numberDiff line numberDiff line change
@@ -8192,14 +8192,30 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
81928192
linkend="datatype-datetime"/>.
81938193
</para>
81948194

8195+
<para>
8196+
In addition, the usual comparison operators shown in
8197+
<xref linkend="functions-comparison-op-table"/> are available for the
8198+
date/time types. Dates and timestamps (with or without time zone) are
8199+
all comparable, while times (with or without time zone) and intervals
8200+
can only be compared to other values of the same data type. When
8201+
comparing a timestamp without time zone to a timestamp with time zone,
8202+
the former value is assumed to be given in the time zone specified by
8203+
the <xref linkend="guc-timezone"/> configuration parameter, and is
8204+
rotated to UTC for comparison to the latter value (which is already
8205+
in UTC internally). Similarly, a date value is assumed to represent
8206+
midnight in the <varname>TimeZone</varname> zone when comparing it
8207+
to a timestamp.
8208+
</para>
8209+
81958210
<para>
81968211
All the functions and operators described below that take <type>time</type> or <type>timestamp</type>
81978212
inputs actually come in two variants: one that takes <type>time with time zone</type> or <type>timestamp
81988213
with time zone</type>, and one that takes <type>time without time zone</type> or <type>timestamp without time zone</type>.
81998214
For brevity, these variants are not shown separately. Also, the
82008215
<literal>+</literal> and <literal>*</literal> operators come in commutative pairs (for
8201-
example both date + integer and integer + date); we show only one of each
8202-
such pair.
8216+
example both <type>date</type> <literal>+</literal> <type>integer</type>
8217+
and <type>integer</type> <literal>+</literal> <type>date</type>); we show
8218+
only one of each such pair.
82038219
</para>
82048220

82058221
<table id="operators-datetime-table">

0 commit comments

Comments
 (0)