Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJKes-0000BB-98 for pgsql-general@arkaria.postgresql.org; Sat, 12 Oct 2019 16:54:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iJKds-0006tH-NL for pgsql-general@arkaria.postgresql.org; Sat, 12 Oct 2019 16:53:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJKds-0006sr-Cl for pgsql-general@lists.postgresql.org; Sat, 12 Oct 2019 16:53:20 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJKdl-0003Qm-92 for pgsql-general@postgresql.org; Sat, 12 Oct 2019 16:53:19 +0000 Received: from [192.168.127.1] (port=60081 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1iJKdj-0009cn-BL; Sat, 12 Oct 2019 16:53:11 +0000 Received: from localhost ([127.0.0.1]:30776 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.92.1 (FreeBSD)) (envelope-from ) id 1iJKdj-0009KD-5k; Sat, 12 Oct 2019 16:53:11 +0000 From: Andrew Gierth To: "Abraham\, Danny" Cc: Adrian Klaver , "pgsql-general\@postgresql.org" Subject: Re: day interval In-Reply-To: <0e252354f16a45dfa672d5346089a224@phx-exmbprd-01.adprod.bmc.com> (Danny Abraham's message of "Sat, 12 Oct 2019 16:34:18 +0000") Message-ID: <87mue5x60l.fsf@news-spur.riddles.org.uk> References: <8736fyxa2a.fsf@news-spur.riddles.org.uk> <279cfb68-22c7-c5c6-95ec-8234831faf38@aklaver.com> <0e252354f16a45dfa672d5346089a224@phx-exmbprd-01.adprod.bmc.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (berkeley-unix) Date: Sat, 12 Oct 2019 17:53:11 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Abraham" == Abraham, Danny writes: Abraham> The problematic code is: Abraham> select date(cm_curr_date) - date(CM_DATE) into diff_days from CMS_SYSPRM; This will always return an integer, unless either the date() cast or the -(date,date) operator have been redefined or modified. Abraham> The fix is: Abraham> select date_part ('day', age( date(cm_curr_date), date(CM_DATE))) into diff_days from CMS_SYSPRM; This doesn't do the same thing, it will give a different result if the dates differ by a month or more. Abraham> The problem: Abraham> How to recreate the problem. (You know - QA). Abraham> Tried changing lc_time, timezone and datestyle .. but nothing Abraham> seems to work None of these things can affect data types. -- Andrew (irc:RhodiumToad)