SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 RR and YY functions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chutestrate
Starting Member

17 Posts

Posted - 01/10/2013 :  20:12:35  Show Profile  Reply with Quote
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

USA
15636 Posts

Posted - 01/10/2013 :  20:17:46  Show Profile  Visit robvolk's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000