oracle的"yy"和"rr"日期掩码有什么区别? [英] What is the difference between oracle's 'yy' and 'rr' date mask?

查看:94
本文介绍了oracle的"yy"和"rr"日期掩码有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:

select ename from emp where hiredate = todate('01/05/81','dd/mm/yy')

select ename from emp where hiredate = todate('01/05/81','dd/mm/rr')

返回不同的结果

推荐答案

YY允许您仅检索一年中的两位数字,例如,99位 1999.其他数字(19)自动分配给当前 世纪. RR通过四舍五入将两位数的年份转换为四位数的年份.

YY allows you to retrieve just two digits of a year, for example, the 99 in 1999. The other digits (19) are automatically assigned to the current century. RR converts two-digit years into four-digit years by rounding.

50-99存储为1950-1999,日期以00-49结尾的存储为 2000-2049. "RRRR"接受四位数的输入(尽管不是必需的),并且 与RR一样转换两位数的日期. YYYY接受4位数输入,但不接受 进行任何日期转换

50-99 are stored as 1950-1999, and dates ending in 00-49 are stored as 2000-2049. RRRR accepts a four-digit input (although not required), and converts two-digit dates as RR does. YYYY accepts 4-digit inputs butdoesn't do any date converting

基本上,您的第一个示例将假设81是2081,而RR则假定是1981.因此,第一个示例不应返回任何行,因为您很可能在2081年5月1日之后还没有雇用任何人:-)

Essentially, your first example will assume that 81 is 2081 whereas the RR one assumes 1981. So the first example should not return any rows as you most likely did not hire any guys after May 1 2081 yet :-)

这篇关于oracle的"yy"和"rr"日期掩码有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆