TO_DATE method in Oracle SQL is generating an unintentional Timestamp, how to remove it?

Asked

Viewed 19 times

0

I have a column called 'periodo_filter' with date of type (data1 A data2), example: (01/1/2000 A 19/1/2020). With the following code I am removing the first date from this column and creating a new table with it:

CREATE TABLE MINHA_TABELA_NOVA AS (SELECT
     TO_DATE(TRIM(SUBSTR(periodo_filtro, 1,
    INSTR(periodo_filtro, ' ', 1, 1))), 'dd/mm/yyyy') periodo_inicial
FROM
    MINHA_TABELA);

put the result is as follows:

resultado

How do I get this timestamp (12:00:00) removed from this column? I want to keep only the date information

  • 1

    Convert to char again and leave in the format you need, for example SELECT TO_CHAR(TO_DATE('13/07/2021','DD/MM/YYYY'),'DD/MM/YYYY') DATA FROM DUAL

  • worked perfectly, but I just realized that I would need this data on date type, for future manipulations. There is another alternative?

  • 1

    the date type tracks the time, even if q is a "00:00:00", I suggest to keep it that way and switch to the format you want when showing the value

  • 1

    I understand! I will follow this way. Thanks for the answers

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.