Я получил этот код ...
select
cast((DATEDIFF(year, StartDate, getdate()))as CHAR(3)) +'years '+
case when (datediff(DAY,DATEADD(month,DATEDIFF(month,DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte), getdate()),
DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte)),GETDATE()))<0
then
cast(DATEDIFF(month,DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte), getdate()) -1 AS CHAR(2))
else
cast (DATEDIFF(month,DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte), getdate())AS CHAR(2))
end +'months '+
-------------------------------------------
case when (datediff(DAY,DATEADD(month,DATEDIFF(month,DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte), getdate()),
DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte)),GETDATE()))<0
then
cast(datediff(DAY,DATEADD(month,DATEDIFF(month,DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte), getdate())-1,
DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte)),GETDATE()) as CHar(2))
else
cast(datediff(DAY,DATEADD(month,DATEDIFF(month,DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte), getdate()),
DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte)),GETDATE())as Char(2))
end+'days' as
Lenghtofservice
--DATEADD(year,(DATEDIFF(year, StartDate, getdate())),StartDAte))
from dbo.Employee