36

I need to get the current 2 digit year and increment by one. So the current number I'm looking for should be 11. How?

3
  • 2
    What result do you want in 2099? ;)
    – AakashM
    Sep 14, 2010 at 10:50
  • 40
    I want to be retired and not care :) Sep 14, 2010 at 10:53
  • The title of this question should be "get the 2 digit year +1" :)
    – b_levitt
    Aug 26, 2021 at 21:36

7 Answers 7

54

You can do ( YEAR( GETDATE() ) % 100 ) + 1

See GETDATE & YEAR

1
  • 7
    and do the + 1 before the % 100, if you want xx99 to yield 0 rather than 100
    – AakashM
    Sep 14, 2010 at 17:01
32

This will work for you

select Right(Year(getDate())+ 1,2)
0
15

For SQL Server 2012 and above, I'd suggest using FORMAT(@DATE, 'yy'):

SELECT FORMAT(DATEADD(year, 1, GETDATE()), 'yy')

Format offers a cleaner, more readable solution. Thus, less guesswork, and a better maintainability.

1
  • @VeryColdAir The original question was ` get the current 2-digit year and increment by one`.
    – wp78de
    Jul 20, 2022 at 15:01
7
SELECT RIGHT(CONVERT(VARCHAR(8), GETDATE(), 1),2) as YEAR
6

You can try this in sql server

SELECT FORMAT(GETDATE(), 'yy')
1
  • 1
    This does not answer the OP's question of getting the current year + 1.
    – wp78de
    Jul 20, 2022 at 15:02
0

If you are always going to be using GetDate() why not just do something like this:

Select (Year(GetDate()) - 2000) + 1

Dang people. Always making things so complicated. It's not like you are going to be living for another 1000 years!

-2
select CAST( DAY(GETDATE()) as varchar(10))+'/'+CAST( month(GETDATE()) as varchar(10))+'/' +cast(right(year(getDate()),2) as varchar)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.