From: Tom Lane Date: Wed, 30 Dec 2020 22:48:43 +0000 (-0500) Subject: Doc: spell out comparison behaviors for the date/time types. X-Git-Tag: REL9_5_25~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7fe23c8bb5d2de892796594a66bc7a3292c6302c;p=thirdparty%2Fpostgresql.git 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 --- diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 3a25162d8c4..c6d21c5f43b 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -6459,6 +6459,21 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}'); linkend="datatype-datetime">. + + In addition, the usual comparison operators shown in + 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 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 TimeZone zone when comparing it + to a timestamp. + + All the functions and operators described below that take time or timestamp inputs actually come in two variants: one that takes time with time zone or timestamp