MM-DD-RRRR / MM-DD-YYYY 的区别 (Date format)

先各位执行一下下面SQL. 结果会如何呢?
select to_date('05/01/02','YYYY-MM-DD') YYYY ,to_date ('05/01/02','RRRR-MM-DD') RRRR
from dual
结果如下:
-------------------------------------------------
YYYY RRRR
0005-01-02 00:00:00 2005-01-02 00:00:00
-------------------------------------------------
什么原因 ?
RR
Yes Lets you store 20th century dates in the 21st century using only two digits.
See Also: Additional discussion on RR datetime format element in the Oracle Database SQL Reference

RRRR
Yes Round year. Accepts either 4-digit or 2-digit input. If 2-digit, provides the same return as RR. If you do not want this functionality, then enter the 4-digit year.
RRRR这边说得如果你输入的是2位数字 则会转换为 四位年,如果是四位年,则保持不变。
而 YYYY 只是将同一位置上的字符转换为要求的字符,如果为数不够则用0 补充。
这就是RRRR /YYYY 的区别!
By -myhuaer
[@more@]
请使用浏览器的分享功能分享到微信等