Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9ojm-0007lv-D2 for pgsql-general@arkaria.postgresql.org; Fri, 08 Jul 2022 14:13:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9ojl-00036P-33 for pgsql-general@arkaria.postgresql.org; Fri, 08 Jul 2022 14:13:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9ojk-00033L-OT for pgsql-general@lists.postgresql.org; Fri, 08 Jul 2022 14:13:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9oji-0003wP-F5 for pgsql-general@lists.postgresql.org; Fri, 08 Jul 2022 14:13:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 268EDVlu3307201; Fri, 8 Jul 2022 10:13:31 -0400 From: Tom Lane To: Christoph Moench-Tegeder cc: Rajesh S , pgsql-general@lists.postgresql.org Subject: Re: - operator overloading not giving expected result In-reply-to: References: <7f97243d-db62-199a-8412-5637963d117e@fincuro.com> Comments: In-reply-to Christoph Moench-Tegeder message dated "Fri, 08 Jul 2022 14:46:54 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3307199.1657289611.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 08 Jul 2022 10:13:31 -0400 Message-ID: <3307200.1657289611@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Christoph Moench-Tegeder writes: > ## Rajesh S (rajesh.s@fincuro.com): >> We are migrating our database from Oracle to Postgresql.  In oracle we >> have used this syntax "SELECT ('1999-12-30'::DATE) - >> ('1999-12-11'::DATE)" to get difference between two dates as a integer >> output (ex: 19).  But in Postgres the same query returns result as "19 >> days". > There's something fishy going on, as (date) - (date) returns integer > since a very long time (even the version 8.0 docs have that). > On the other hand, (timestamp) - (timestamp) gives an interval, so > first make sure you really got the data types right. It's easy to demonstrate that that query does indeed return "19" in stock Postgres. Therefore, this is not stock Postgres. >>     LANGUAGE 'edbspl' > Is this really PostgreSQL or is it that fork - and if it's the fork, > does it behave the same way as stock PostgreSQL does? I'm no expert in this area, but my recollection is that Oracle's type DATE is more nearly what we'd call TIMESTAMP (i.e., it includes sub-day fields), and that EDB's fork follows Oracle's datatype naming. So I'd not be at all surprised by this result if it's on EDB. BTW, Oracle doesn't really accept "::" casting notation does it? I always thought that was a pure Postgres-ism. regards, tom lane