At Oracle, why is this coming back on March 1st?

In Oracle, this returns 01/03/2010. That doesn't make sense to me. Does anyone know why?

SELECT TO_DATE( '2010' ,'yyyy' ) AS STRANGE_YEAR_RESULT FROM DUAL 

I tried Oracle 10g and 11g.

+4
source share
3 answers

Oracle needs the full DateTime value in a Date value field, which makes it an occupation on the first day of the current month, I would assume since you did not need any other information except for the year. Remember that you always need to pass dates through TO_DATE () and TO_CHAR () in Oracle. Assuming that Oracle “knows” that you will receive the required information.

+4
source

I don’t think there is a reasonable reason, it’s just “what he does.” It was also discussed on the OTN forums about a year ago.

0
source

I don’t know, but I think that the months are based on zero, therefore Jan = 0, Mar = 2, etc.

"10" may be a Y2K issue when created, but it is interpreted as 2010.

And if not a single day of the month is indicated, it may take the first day of the month.

Why check it out? You will never want to code this path.

0
source

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


All Articles