MM-DD-RRRR / MM-DD-YYYY 的区别【Blog 搬家】

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.
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/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值