Oracle date seems equals

前端 未结 2 1152
时光取名叫无心
时光取名叫无心 2021-01-19 17:46

there is a table INCASSO in my database:

CREATE TABLE \"GEC_AP\".\"INCASSO\" 
(\"ID_INCASSO\" VARCHAR2(50 BYTE) NOT NULL ENABLE,
 \"ID_FATTURA\" VARCHAR2(50          


        
2条回答
  •  难免孤独
    2021-01-19 17:52

    Change the date format to DD-MON-YYYY HH24:MI:SS and you are likely to see the difference in that the dates have different centuries.

    Using RR to format the year can hide that one date is 1911 and the other is 2011

    Try:

    SELECT TO_CHAR( DATE '2011-01-01', 'RR-MM-DD' ),
           TO_CHAR( DATE '1911-01-01', 'RR-MM-DD' )
    FROM   DUAL
    

    Both will output the same although they are different dates and will not be grouped together.

    If the dates are still the same then look for additional spaces or other hidden characters in the strings; you can use LENGTH() to check the size of the strings or DUMP() to get the byte values of the contents:

    select id_incasso,
           id_fattura,
           LENGTH( id_fattura ) AS f_length,
           id_piano_rate,
           LENGTH( id_piano_rate ) AS pr_length,
           TO_CHAR( data_esecuzione, 'YYYY-MM-DD HH24:MI:SS' ) AS data_esecuzione
    from   incasso
    where  id_incasso = 'TO_20110521258225'
    

提交回复
热议问题