> On 27/04/2023 13:20 CEST gzh <gzhcoder@126.com> 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