Hi Mayeso,
Please look into the below example.
I hope it will give clear solution for u
create table #temp1
(
name varchar(10),
dateofbirth datetime,
sex varchar(10),
qualification varchar(10) ,
firstappointmentdate datetime,
grade varchar,
dateofli datetime ,
dateofaut datetime,
datofappt datetime)
select * from #temp1
insert into #temp1 values('arul','1989-03-23','male','BE','2010-09-21','B','2009-07-20' ,
'2009-05-20','2010-07-20')
select name, DATEDIFF(yy,dateofbirth,GETDATE())as DOB,sex,qualification,
DATEDIFF(yy,firstappointmentdate,GETDATE()) as [Year Of Services],
DATEDIFF(yy,datofappt,GETDATE()) as [years at current grade]