-
what's the difference between
date DD-MON-YY vs DD-MON-RRRR
-
SQL> select to_char(sysdate, 'DD-MON-YY') from dual;
TO_CHAR(S
---------
13-DEC-00
SQL> select to_char (sysdate, 'DD-MON-RRRR') from dual;
TO_CHAR(SYS
-----------
13-DEC-2000
SQL>
-
YY implies the current century while
RR implies the Previous century
For example: (assuming table=Test_table, column=date1)
insert into test_table (date1)
values (to_date('02/01/95','MM/DD/YY')); will insert Feb, 1, 2095 into the table while
insert into test_table (date1)
values (to_date('02/01/95','MM/DD/RR')); will insert Feb, 1, 1995
You can check this with :
Select to_char(date1,'MM/DD/YYYY') from test_table.
Result
02/01/1995
02/01/2095
I hope this clarifies your question.
Robel.
-
Actually, neither answer is quite correct. Here it is from the docs:
RR
Given a year with 2 digits, returns a year in the next century if the year is <50 and the last 2 digits of the current year are >=50; returns a year in the preceding century if the year is >=50 and the last 2 digits of the current year are <50.
RRRR
Round year. Accepts either 4-digit or 2-digit input. If 2-digit, provides the same return as RR. If you don't want this functionality, simply enter the 4-digit year.
YYYY
SYYYY
4-digit year; "S" prefixes BC dates with "-".
YYY
YY
Y
Last 3, 2, or 1 digit(s) of year.
So YY will assume that you are talking about this century and will insert 2095 when 95 is entered, and RR will follow the rule that >50 means last century and insert 1995. This is as rmgirma said. However, if you enter 35, both YY and RR will insert 2035. An important distinction.
Hope this helps,
- Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|