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 1iJLKs-0001bT-Ni for pgsql-general@arkaria.postgresql.org; Sat, 12 Oct 2019 17:37:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iJLJr-0004iN-2W for pgsql-general@arkaria.postgresql.org; Sat, 12 Oct 2019 17:36:43 +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 1iJLJq-0004i8-O5 for pgsql-general@lists.postgresql.org; Sat, 12 Oct 2019 17:36:42 +0000 Received: from mx-us-phx-04.bmc.com ([198.147.194.159] helo=mx-us-phx-04-int.bmc.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJLJk-0003n0-6z for pgsql-general@postgresql.org; Sat, 12 Oct 2019 17:36:42 +0000 Received: from pps.filterd (mx-us-phx-04-int.bmc.com [127.0.0.1]) by mx-us-phx-04-int.bmc.com (8.16.0.27/8.16.0.27) with SMTP id x9CHZaaF023162; Sat, 12 Oct 2019 17:36:31 GMT Received: from phx-exmbprd-02.adprod.bmc.com ([172.24.33.167]) by mx-us-phx-04-int.bmc.com with ESMTP id 2vk7539kcw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 12 Oct 2019 17:36:31 +0000 Received: from PHX-EXMBPRD-01.adprod.bmc.com (172.24.35.196) by phx-exmbprd-02.adprod.bmc.com (172.24.33.167) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 12 Oct 2019 12:36:30 -0500 Received: from PHX-EXMBPRD-01.adprod.bmc.com ([172.24.31.226]) by phx-exmbprd-01.adprod.bmc.com ([172.24.31.226]) with mapi id 15.00.1497.000; Sat, 12 Oct 2019 12:36:30 -0500 From: "Abraham, Danny" To: Andrew Gierth CC: Adrian Klaver , "pgsql-general@postgresql.org" , "Abraham, Danny" Thread-Topic: [EXTERNAL] Re: day interval Thread-Index: AQHVgR2ON9d2s+ktb0KdYFRN/F1iZ6dXRGWA Date: Sat, 12 Oct 2019 17:36:29 +0000 Message-ID: References: <8736fyxa2a.fsf@news-spur.riddles.org.uk> <279cfb68-22c7-c5c6-95ec-8234831faf38@aklaver.com> <0e252354f16a45dfa672d5346089a224@phx-exmbprd-01.adprod.bmc.com> <87mue5x60l.fsf@news-spur.riddles.org.uk> In-Reply-To: <87mue5x60l.fsf@news-spur.riddles.org.uk> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [192.168.6.253] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: Re: day interval X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-12_09:,, signatures=0 X-Proofpoint-Spam-Reason: safe List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thanks for the clarification. The problem is still this: select date('20191001') - date('20190101') ; in my servers it is always '273'. In the customer's DB it is '273 days'; Thanks Danny -----Original Message----- From: Andrew Gierth =20 Sent: Saturday, October 12, 2019 7:53 PM To: Abraham, Danny Cc: Adrian Klaver ; pgsql-general@postgresql.org Subject: [EXTERNAL] Re: day interval >>>>> "Abraham" =3D=3D 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 date= s 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 Ab= raham> seems to work None of these things can affect data types. -- Andrew (irc:RhodiumToad)