Home > database >  Oracle char type (' 2018 ') turn the date when the system in early time is why
Oracle char type (' 2018 ') turn the date when the system in early time is why

Time:09-22

The select to_date (' 2018 ', 'yyyy) from dual system in early time is why?
For example: select to_date (' 2018 ', 'yyyy) from dual
Result: 20180601

CodePudding user response:

Official document writing it
https://docs.oracle.com/database/121/SQLRF/sql_elements001.htm#SQLRF0021

The default date values are determined as follows:

The year is The current year, as returned by SYSDATE.

The month is The current month, as returned by SYSDATE.

The day is 01 (The first day of The month).

The hour, minute, and second are all 0.


If you want to January 1, use the
The select trunc (to_date (' 2018 ', 'yyyy'), 'y') from dual;
  • Related