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 1iJLNi-0001jM-5c for pgsql-general@arkaria.postgresql.org; Sat, 12 Oct 2019 17:40:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iJLMj-0008Ko-0F for pgsql-general@arkaria.postgresql.org; Sat, 12 Oct 2019 17:39:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJLMh-0008Jm-4z for pgsql-general@lists.postgresql.org; Sat, 12 Oct 2019 17:39:40 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iJLMd-0001mD-Kw for pgsql-general@postgresql.org; Sat, 12 Oct 2019 17:39:37 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id E673353F; Sat, 12 Oct 2019 13:39:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 12 Oct 2019 13:39:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=e 9swrzwzCsSXPUaT6bUi/eyIb7NKXWKAgFlOexfT7nM=; b=xd4p2iaTAj3YDKWc7 mtwY9fWuO1SPNbTwxiq4wl3cxatCgcEAm9srtoPk6osFB2RfZPiTguKaOMdm4835 vlfHbsZ2gotkZanLOhJn5ZxH9XSjlK3IKQ3k2K/LdfwkzoRbHHb7EO6RTnIYi3vh ROvg/S+Z1PYIoDPc7vE5rZ+et7SI4pY5g426YEuV0XWpXBSkKMAnXCutuzsVrs+V 38kJt0sOF5TWYDztwe/Ix8kF+y6GENJwd2XLUedpjIgE04+w3EoztOcVrOePrRsn J3HjiypilIx+obPP2xAXiZA2nID5Mv68tgKrEp87rkLPUQfkW2lvmSAc9Iwffc/N WXKZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=e9swrzwzCsSXPUaT6bUi/eyIb7NKXWKAgFlOexfT7 nM=; b=JZdJQfG10D2BVI0xdmAYrUBP0OLgCaCXTQTxc30sJ/KD2e3Ty9Ble8XK3 1jv9Yhw8hWUyAMWC7hjFwB0RK3b1jjzLMQTag4I024+qzYXMfqEyJpIfgK/60Jhy ECP2gfnYmaa1NxGHu8l8gUWNmzOy2/8w5nf2GU/3zj5OFxjPJzWCCU+356ZVMsMv zLvg5ZKXzcmYM80qlFl3ItmVzWJPxkMGQh4IC66YlOINwNv5lxm1hDhtW4mv/sw6 yzx06m/+u1wMydOeBJJmBpeyqIAtQfSKmFTCQZuGpvPdDOPWsd8l5iSg+ihuWuYd 3ncA3xnKvtqcTAN1Q3xN8ozujKdAw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrieejgdduudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucffohhmrghinhepsghmtgdrtghomhenucfkphepudejgedrvddurddufeehrddv tdeinecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkh hlrghvvghrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.2] (174-21-135-206.tukw.qwest.net [174.21.135.206]) by mail.messagingengine.com (Postfix) with ESMTPA id BEB2D80060; Sat, 12 Oct 2019 13:39:32 -0400 (EDT) Subject: Re: day interval To: "Abraham, Danny" Cc: "pgsql-general@postgresql.org" References: <8736fyxa2a.fsf@news-spur.riddles.org.uk> <279cfb68-22c7-c5c6-95ec-8234831faf38@aklaver.com> <0e252354f16a45dfa672d5346089a224@phx-exmbprd-01.adprod.bmc.com> From: Adrian Klaver Message-ID: <565bf6dd-c7e5-8dfb-22ec-9f571a4bbf6b@aklaver.com> Date: Sat, 12 Oct 2019 10:39:31 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <0e252354f16a45dfa672d5346089a224@phx-exmbprd-01.adprod.bmc.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/12/19 9:34 AM, Abraham, Danny wrote: > The problematic code is: > select date(cm_curr_date) - date(CM_DATE) into diff_days from CMS_SYSPRM; > > > The fix is: > select date_part ('day', age( date(cm_curr_date), date(CM_DATE))) into diff_days from CMS_SYSPRM; > > The problem: > How to recreate the problem. (You know - QA). Upstream you said: "This has been working for years on all PG community servers. This happens on an EDB PG 9.6.3." Which version of the EDB Postgres database are you using e.g. their install of the community version or their modified(Advanced?) version? When I search on CMS_SYSPRM it comes related to bmc.com, is that in the mix also? > > Tried changing lc_time, timezone and datestyle .. but nothing seems to work > > Thanks > > Danny > > -----Original Message----- > From: Adrian Klaver > Sent: Saturday, October 12, 2019 7:27 PM > To: Abraham, Danny ; Andrew Gierth > Cc: pgsql-general@postgresql.org > Subject: [EXTERNAL] Re: day interval > > On 10/12/19 8:37 AM, Abraham, Danny wrote: >> Thanks Andrew. >> >> My code fails since the expression (In a PG/PG SQL function) which >> assumes integer result Now produces the string '8 day'; > > The code is? > >> >> This has been working for years on all PG community servers. >> >> This happens on an EDB PG 9.6.3. >> >> I know the fix, but I need the ability to create the bug in my server, and I do not know how. >> >> Thanks >> >> Danny >> >> >> -----Original Message----- >> From: Andrew Gierth >> Sent: Saturday, October 12, 2019 6:26 PM >> To: Abraham, Danny >> Cc: pgsql-general@postgresql.org >> Subject: [EXTERNAL] Re: day interval >> >>>>>>> "Abraham" == Abraham, Danny writes: >> >> Abraham> Hi >> Abraham> A question on day interval >> >> Abraham> select date('20191001') - date('20190923'); >> >> Abraham> Will provide sometimes '8' - an integer , but sometimes '8 >> Abraham> day' - a string >> >> No, it'll always return an integer. You will only get an interval result if you subtract timestamps rather than dates, for example if one of the operands is actually an expression returning a timestamp. >> >> Give an example of an actual expression you used that returned an interval instead, and we may be able to tell you how to fix it. >> >> -- >> Andrew (irc:RhodiumToad) >> >> >> > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com