Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 RR and YY functions

Author  Topic 

chutestrate
Starting Member

17 Posts

Posted - 2013-01-10 : 20:12:35
I am having major anxiety over understanding this concept. The following discussion was sent to me, and I"m missing something. The second rules of both appear to apply. What is right?

Current year Date from SQL Interpreted by RR Interpreted by YY
1 1994 27-OCT-95 1995 1995
2 1994 27-OCT-10 2010 1910
3 2013 27-OCT-95 1995 2095
4 2013 27-OCT-10 2010 2010

These interpreted values are calculated based on certain rules. These rules are used to receive the interpreted RR and YY values in the above table.

If you use the TO_DATE function with the YY datetime format element, then the year returned always has the same first 2 digits as the current year. If you use the RR datetime format element instead, then the century of the return value varies according to the specified two-digit year and the last two digits of the current year.

That is:

If the specified two-digit year is 00 to 49, then:

- If the last two digits of the current year are 00 to 49, then the returned year has the same first two digits as the current year.


- If the last two digits of the current year are 50 to 99, then the first 2 digits of the returned year are 1 greater than the first 2 digits of the current year.


If the specified two-digit year is 50 to 99, then:

- If the last two digits of the current year are 00 to 49, then the first 2 digits of the returned year are 1 less than the first 2 digits of the current year.


- If the last two digits of the current year are 50 to 99, then the returned year has the same first two digits as the current year.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2013-01-10 : 20:17:46
TO_DATE is an Oracle function, and SQLTeam is a Microsoft SQL Server website. Try the Oracle forum over at http://dbforums.com/
Go to Top of Page
   

- Advertisement -