例子:
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 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 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 日之后还没有雇用任何人:-)
关于sql - oracle的 'yy'和 'rr'日期掩码有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19058/