I need to get the current 2 digit year and increment by one. So the current number I'm looking for should be 11.
我需要得到当前的2位数年,然后增加1。所以现在的数字应该是11。
Probably really simple but I'm a sql noob :)
可能很简单,但我是一个sql noob:)
Thanks
谢谢
4 个解决方案
#1
#2
21
This will work for you
这对你有用
select Right(Year(getDate())+ 1,2)
#3
5
SELECT RIGHT(CONVERT(VARCHAR(8), GETDATE(), 1),2) as YEAR
#4
-3
select CAST( DAY(GETDATE()) as varchar(10))+'/'+CAST( month(GETDATE()) as varchar(10))+'/' +cast(right(year(getDate()),2) as varchar)
#1
33
You can do ( YEAR( GETDATE() ) % 100 ) + 1
您可以做(年(GETDATE()) % 100) + 1。
看到获取日期和年
#2
21
This will work for you
这对你有用
select Right(Year(getDate())+ 1,2)
#3
5
SELECT RIGHT(CONVERT(VARCHAR(8), GETDATE(), 1),2) as YEAR
#4
-3
select CAST( DAY(GETDATE()) as varchar(10))+'/'+CAST( month(GETDATE()) as varchar(10))+'/' +cast(right(year(getDate()),2) as varchar)