The difference between YYYY and RRRR is, YYYY Is
used to show/fetch/store current year in 4 digit whereas RRRR assumes 2 digit year in the range of 0 to 49 in the current
century and in the range of 50 to 99 are assume to be in the previous century.
YYYY
format may not work for in below case:-
SELECT
TO_CHAR(TO_DATE(’21-08-14’,’DD-MM-YYYY’),’DD-MM-YYYY’) DT FROM DUAL;
SELECT
TO_CHAR(TO_DATE('21-08-51','DD-MM-YYYY'),'DD-MM-YYYY') DT FROM DUAL;
Let’s try to use RRRR format:-
SELECT
TO_CHAR(TO_DATE(’21-08-14’,’DD-MM-RRRR’),’DD-MM-YYYY’) DT FROM DUAL;
SELECT
TO_CHAR(TO_DATE('21-08-51','DD-MM-RRRR'),'DD-MM-YYYY') DT FROM DUAL;
But when you want to use only with YYYY format then you should not provide
4 digit year instate you can provide only 2 digit number as shown below:-
SELECT
TO_CHAR(TO_DATE(’21-AUG-14’,’DD-MM-YY’),’DD-MM-YYYY’) DT FROM DUAL;
And below statement will not work for you:-
SELECT
TO_CHAR(TO_DATE(’21-08-14’,’DD-MM-YYYY’),’DD-MM-YYYY’) DT FROM DUAL;
Read Also:-