SELECT TO_CHAR(TO_DATE('27-OCT-98', 'DD-MON-RR') ,'YYYY') "Year"
FROM DUAL;
The Output is : 1998
SELECT TO_CHAR(TO_DATE('27-OCT-98', 'DD-MON-YY') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2098
DD-MON-RR
===========
If the specified two digits year is 0-49 and the two digits of the current
year is 0-49 it returns the current century.
SELECT TO_CHAR(TO_DATE('27-OCT-08', 'DD-MON-RR') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2008
year is 50-99 it returns the century after the current one.
ex: The Current year is 2058
SELECT TO_CHAR(TO_DATE('27-OCT-08', 'DD-MON-RR') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2158
year is 0-49 it returns the century before the current one.
SELECT TO_CHAR(TO_DATE('27-OCT-98', 'DD-MON-RR') ,'YYYY') "Year"
FROM DUAL;
The Output is : 1998
If the specified two digits year is 50-99 and the two digits of the current
year is 50-99 it returns the current century.
ex: The Current year is 2058
SELECT TO_CHAR(TO_DATE('27-OCT-98', 'DD-MON-RR') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2098
DD-MON-YY
===========
But in all of the above scenario's yy will consider this century alone.
===========
But in all of the above scenario's yy will consider this century alone.
SELECT TO_CHAR(TO_DATE('27-OCT-98', 'DD-MON-RR') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2098
SELECT TO_CHAR(TO_DATE('27-OCT-08', 'DD-MON-RR') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2008
Thank you for the excellent article. It has been very helpful.
ReplyDeleteThese examples are very understandable.... and very clear....
ReplyDeleteThanq
Bullet 2. If the specified two digits year is 0-49 and the two digits of the current
ReplyDeleteyear is 50-99 it returns the century after the current one.
ex: The Current year is 2058
SELECT TO_CHAR(TO_DATE('27-OCT-08', 'DD-MON-RR') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2158 ----> I was confused, why it won't return '2108'. Kindly suggest. Thanks in advance.
It should be 2108. i also don't get this particular case. please explain with another example.
DeleteSay-
ReplyDeleteYear 00-49 = L
Year 50-99 = U
1a. Current year = L and RR = L, RR Century = Current.
1b. Current year = U and RR = U, RR Century = Current.
2. Current year = L and RR = U, RR Century = Previous.
3. Current year = U and RR = L, RR Century = Next.
If both RR and the current year
are in the same half of the century,
RR is in the same century.
If RR and and the current year
are in the different half of the century,
RR goes 1 century (+/-) twards the current year (U/L)
Thanks.
In DD-MM-YY explanation part,
ReplyDeleteThere is should be DD-MON-YY instead of DD-MON-RR.
Eg.
SELECT TO_CHAR(TO_DATE('27-OCT-98', 'DD-MON-YY') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2098
SELECT TO_CHAR(TO_DATE('27-OCT-08', 'DD-MON-YY') ,'YYYY') "Year"
FROM DUAL;
The Output is : 2008
Please let me correct if i am wrong here.