date DD-MON-YY vs DD-MON-RRRR
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: date DD-MON-YY vs DD-MON-RRRR

Hybrid View

  1. #1
    Join Date
    Oct 2000
    Posts
    56
    what's the difference between
    date DD-MON-YY vs DD-MON-RRRR

  2. #2
    Join Date
    Jun 2000
    Posts
    417
    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>

  3. #3
    Join Date
    Nov 2000
    Location
    Atlanta, GA, USA
    Posts
    85
    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.

  4. #4
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    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
  •  



Click Here to Expand Forum to Full Width