SQL 2012 Generate 4 digit years from 2 and 3 digit year codes

Hey there!

I'm working in SQL 2012.  I have a year field represented as a 2 or 3 digit number.  If the century is 1900 it's a 2 digit number (e.g., 89=2009).  If the century is 2000 it's a three digit number starting with 1 (e.g., 100=2000) .

I'm trying to figure out a way to create a 4 digit year value given the 2 or 3 digit year code.  

I'm not even sure where to start.  I was thinking a case statement but the years range about 50 years in time so it'd get a bit tedious.  

Any idea?  

Thanks in adavance!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenDBACommented:
Hi ttist,

Just add 1900 to the code.  If the code is two digits the result will be a value between 1900 and 1999.  If the code is 100 or greater you'll get a year of 2000 or greater.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ttist25Author Commented:
Awesome!  WOrked perfectly.  

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.