Oracle Function TO_DATE

I always thought that to_date function string and date format should match. Why does the following expression work?

select TO_DATE('20151014','yyyy-mm-dd') from dual; 

Is oracle now ignoring special characters before converting a string to a date?

This is in Oracle 11g.

+5
source share
1 answer

I found this interesting and asked Google, who told me that basically, when the formats do not match, Oracle tries to make it harder:

https://asktom.oracle.com/pls/apex/f?p=100:11:::NO:RP:P11_QUESTION_ID:9522299800346947976

http://www.oracledba.co.uk/tips/dates_8i.htm

You can use the format string "FX" to match exactly:

http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements004.htm#r18c1-t65

http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements004.htm#SQLRF00216

You will learn something new every day! Thanks for asking about this!

+5
source

Source: https://habr.com/ru/post/1234316/


All Articles