Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Date Timestamp Functions
 

Using the RR Format

If your date format is RR and you supply the last two digits of a year, the first two digits of your year are determined using the two-digit year you supply (your supplied year) and the last two digits of the present date on your database server (the present year). The rules used to determine the century of your supplied year are as follows: Rule 1 If your supplied year is between 00 and 49 and the present year is between 00 and 49, the century is the same as the present century. Therefore, the first two digits of your supplied year are set to the first two digits of the present year. For example, if your supplied year is 15 and the present year is 2005, your supplied year is set to 2015. Rule 2 If your supplied year is between 50 and 99 and the present year is between 00 and 49, the century is the present century minus 1. Therefore, the first two digits of your supplied year are set to the present year's first two digits minus 1. For example, if your supplied year is 75 and the present year is 2005, your supplied year is set to 1975. Rule 3 If your supplied year is between 00 and 49 and the present year is between 50 and 99, the century is the present century plus 1. Therefore, the first two digits of your supplied year are set to the present year's first two digits plus 1. For example, if your supplied year is 15 and the present year is 2075, your supplied year is set to 2115. Rule 4 If your supplied year is between 50 and 99 and the present year is between 50 and 99, the century is the same as the present century. Therefore, the first two digits of your supplied year are set to the first two digits of the present year. For example, if your supplied year is 55 and the present year is 2075, your supplied year is set to 2055. Quote from: Oracle Database 10g SQL (Osborne ORACLE Press Series) (Paperback) # Paperback: 608 pages # Publisher: McGraw-Hill Osborne Media; 1st edition (February 20, 2004) # Language: English # ISBN-10: 0072229810 # ISBN-13: 978-0072229813 SQL> SQL> SELECT   2    TO_CHAR(TO_DATE('04-JUL-15', 'DD-MON-RR'), 'DD-MON-YYYY'),   3    TO_CHAR(TO_DATE('04-JUL-75', 'DD-MON-RR'), 'DD-MON-YYYY')   4  FROM dual; TO_CHAR(TO_ TO_CHAR(TO_ ----------- ----------- 04-JUL-2015 04-JUL-1975 SQL>