sql - oracle的 'yy'和 'rr'日期掩码有什么区别?

标签 sql oracle

例子:

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')

返回不同的结果

最佳答案

http://oracle.ittoolbox.com/groups/technical-functional/oracle-dev-l/difference-between-yyyy-and-rrrr-format-519525

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/

相关文章:

sql - sql中的日期时间比较错误?

java - 有条件地在 jooq 准备好的语句中包含子句

Oracle外键执行计划?

database - 带where子句执行的sql查询

java - 使用 Java 检查数据库是否正在运行

mysql - SQL:按foreign_key数字列表排序

sql - 从结果集创建长字符串

mysql - 连接列上的 SQL 过滤器查询

python - 将表数据从django postgres模型推送到远程oracle数据库

oracle - 将 Crystal Report 命令参数传递给 Oracle 函数