简体   繁体   中英

ORACLE SQL ignore to_date comparison

I'm stuck with a trivial date comparison:

my query return a set of 3 record, posted below

在此处输入图片说明

adding to the where clause the condition:

halaffecteddate <= to_date('20-03-20 23:43:00','dd-mm-YYYY HH24:MI:SS')

it returns only one record (line 4)

Can someone could explain why?

Does it depend on the client's date format?

I'm using oracle sql developer

This code:

to_date('20-03-20 23:43:00','dd-mm-YYYY HH24:MI:SS')

Will become a date of 20-MAR- 0020 23:43:00 because specifying YYYY causes oracle to parse 20 as 0020 rather than 2020

We can't really see what dates you truly have in your table, because they're two digits, but the only way that "just row 4" will be returned from this clause is if the date in the halaffecteddate of row 4 is also year 0020 . Perhaps add another column to your query: EXTRACT(YEAR FROM haleffectivedate) and see if it returns 20 or 2020 for row 4 - my guess is that it will return 20

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM