aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-12-30 17:48:43 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-12-30 17:48:43 -0500
commite3bfdf216166f5464235e71fc812e48454718f49 (patch)
treef2e646bc4d4268df619309e6008f681c694bd4c5
parent3ca19490b4f8875c802999a62a207f9dabe813b2 (diff)
downloadpostgresql-e3bfdf216166f5464235e71fc812e48454718f49.tar.gz
postgresql-e3bfdf216166f5464235e71fc812e48454718f49.zip
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
-rw-r--r--doc/src/sgml/func.sgml20
1 files changed, 18 insertions, 2 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 56becc31fd3..dbf33cf5903 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -7246,13 +7246,29 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
</para>
<para>
+ In addition, the usual comparison operators shown in
+ <xref linkend="functions-comparison-op-table"/> are available for the
+ date/time types. Dates and timestamps (with or without time zone) are
+ all comparable, while times (with or without time zone) and intervals
+ can only be compared to other values of the same data type. When
+ comparing a timestamp without time zone to a timestamp with time zone,
+ the former value is assumed to be given in the time zone specified by
+ the <xref linkend="guc-timezone"/> configuration parameter, and is
+ rotated to UTC for comparison to the latter value (which is already
+ in UTC internally). Similarly, a date value is assumed to represent
+ midnight in the <varname>TimeZone</varname> zone when comparing it
+ to a timestamp.
+ </para>
+
+ <para>
All the functions and operators described below that take <type>time</type> or <type>timestamp</type>
inputs actually come in two variants: one that takes <type>time with time zone</type> or <type>timestamp
with time zone</type>, and one that takes <type>time without time zone</type> or <type>timestamp without time zone</type>.
For brevity, these variants are not shown separately. Also, the
<literal>+</literal> and <literal>*</literal> operators come in commutative pairs (for
- example both date + integer and integer + date); we show only one of each
- such pair.
+ example both <type>date</type> <literal>+</literal> <type>integer</type>
+ and <type>integer</type> <literal>+</literal> <type>date</type>); we show
+ only one of each such pair.
</para>
<table id="operators-datetime-table">