SQL Server中有获取年份和月份的函数YEAR 和 MONTH。话不多说,上例子,
SELECT GETDATE() date, YEAR(GETDATE()) as year, MONTH(GETDATE()) as month
结果如下: