取工作年限
DECLARE @WorkDate DATETIME
SET @WorkDate='2010-2-20'
select DATEDIFF(YY,@WorkDate,GETDATE()),
DATEDIFF(MM,@WorkDate,GETDATE()),
DATEDIFF(d,@WorkDate,GETDATE()),
case when DATEADD(year,DATEDIFF(YY,@WorkDate,GETDATE()),@WorkDate)>GETDATE()-1 THEN DATEDIFF(YY,@WorkDate,GETDATE())-1
ELSE DATEDIFF(YY,@WorkDate,GETDATE()) END AS WorkYear