ITPub博客

首页 > 数据库 > Oracle > Oracle concept 学习 2--DATE类型的RR和YY

Oracle concept 学习 2--DATE类型的RR和YY

原创 Oracle 作者:hkywgz 时间:2014-12-16 11:20:20 0 删除 编辑
原文:

RR is similar to YY (the last two digits of the year), but the century of the return value varies according to the specified two-digit year and the last two digits of the current year. Assume that in 1999 the database displays 01-JAN-11. If the date format uses RR, then 11 specifies 2011, whereas if the format uses YY, then 11 specifies 1911. You can change the default date format at both the instance and the session level.

 



RR 是区分世纪, YY不区分.
如果输入的两位数是00-49:
如果当前年份属于00-49,则返回成本世纪所在年份;
如果当前年份属于50-99,则返回成下世纪所在年份。
如果输入的两位数是50-99:
如果当前年份属于00-49,则返回成上世纪所在年份
如果当前年份属于50-99,则返回成本世界所在年份
注:这种自动转换只适用于 String -> Date 的转换,如果是 Date -> String,那就按照 Date 存储的值来转换,此时再用 RR/RRRR 已经没有意义了,因为 Oracle 内部存储的年份是四位数的

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28826508/viewspace-1369299/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-12-16

  • 博文量
    6
  • 访问量
    14223