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 1ps1Yi-0000Nx-0W for pgsql-general@arkaria.postgresql.org; Thu, 27 Apr 2023 13:21:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ps1Yf-0000m4-30 for pgsql-general@arkaria.postgresql.org; Thu, 27 Apr 2023 13:21:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ps1Ye-0000lv-OG for pgsql-general@lists.postgresql.org; Thu, 27 Apr 2023 13:21:12 +0000 Received: from mout-u-107.mailbox.org ([2001:67c:2050:101:465::107]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ps1YX-002BCg-45 for pgsql-general@lists.postgresql.org; Thu, 27 Apr 2023 13:21:11 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4Q6bwB3kVqz9sRp; Thu, 27 Apr 2023 15:20:58 +0200 (CEST) Date: Thu, 27 Apr 2023 15:20:57 +0200 (CEST) From: Erik Wienhold To: gzh Cc: pgsql-general@lists.postgresql.org Message-ID: <1680302275.1289710.1682601657505@office.mailbox.org> In-Reply-To: <7480a292.7dc7.187c271a743.Coremail.gzhcoder@126.com> References: <328d2a0.828a.18799afd0ac.Coremail.gzhcoder@126.com> <1597875806.606392.1681915893771@office.mailbox.org> <70c95d95.7a58.1879a77ed4f.Coremail.gzhcoder@126.com> <2993958.1681924695@sss.pgh.pa.us> <5027d9b9.7aad.187b831fb18.Coremail.gzhcoder@126.com> <1073908593.624606.1682427189969@office.mailbox.org> <7480a292.7dc7.187c271a743.Coremail.gzhcoder@126.com> Subject: Re: Re:Re: psql:t_mstr.sql:994: ERROR: function to_char(numeric) does not exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 27/04/2023 13:20 CEST gzh wrote: > > When the return type is set to oracle.date, there are hours, minutes, and > seconds of the date value in the SQL execution result. > Why is there such a difference and how to solve it? orafce defines oracle.date as timestamp(0) [0] because Oracle's DATE type has a precision of one second [1]. That's the point of orafce: to provide Oracle compatibility. You can cast oracle.date to pg_catalog.date but then you're in Postgres territory again. Depends on what you want to achieve. If it's just formatting use oracle.to_char: SELECT oracle.to_char('2023-04-27'::oracle.date, 'YYYY-MM-DD'); [0] https://github.com/orafce/orafce/blob/VERSION_3_24_4/orafce--3.24.sql#L343 [1] https://oracle-base.com/articles/misc/oracle-dates-timestamps-and-intervals#date -- Erik