Sunday, April 20, 2014

Select people older than 65

Hi,


Try this it may be helpful:



declare @people table (name varchar(20),[birth date] datetime)
insert @people values ('A','20/10/1900')
insert @people values ('B','20/10/1940')
insert @people values ('C','20/10/1960')
insert @people values ('D','20/10/1970')
insert @people values ('F','20/10/1980')
select datediff(year,[birth date],getdate()) from @people
select *,datediff(year,[birth date],getdate()) diff
from @people where datediff(year,[birth date],getdate()) > 65



Best regards.


No comments:

Post a Comment