Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the 2 digit year in T-SQL

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

Probably really simple but I'm a sql noob :)

Thanks

like image 397
fearofawhackplanet Avatar asked Sep 14 '10 10:09

fearofawhackplanet


People also ask

How can I get two digit date in SQL?

SELECT RIGHT('0' + RTRIM(MONTH('12-31-2012')), 2);

How do I find a specific year in SQL?

If you use SQL Server, you can use the YEAR() or DATEPART() function to extract the year from a date.


1 Answers

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

See GETDATE & YEAR

like image 190
Jon Freedman Avatar answered Sep 26 '22 07:09

Jon Freedman