MM-DD-RRRR / MM-DD-YYYY 的区别 (Date format)
2005 年 08 月 15日
先各位执行一下下面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.
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
myhuaer 发表于:2005.08.15 10:50 ::分类: ( Oracle Infomation ) ::阅读:(491次)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/34596/viewspace-661930/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/34596/viewspace-661930/