declare @dtBirthDate datetime
declare @dtThisDate datetime
set @dtBirthDate = '1980-7-1'
set @dtThisDate = getdate()
declare @nYear int
select @nYear = datediff(yy, @dtBirthDate, @dtThisDate)
select age = case when datediff(dd, dateadd(yy, @nYear, @dtBirthDate), @dtThisDate) < 0 then @nYear - 1 else @nYear end
declare @Birthday datetime
set @Birthday='1976-4-6'
select case when dateadd(yy,DATEDIFF(yy, @Birthday, GETDATE()),@Birthday)>getdate()
then DATEDIFF(yy, @Birthday, GETDATE())
else DATEDIFF(yy, @Birthday, GETDATE())+1
end
set @Birthday='1976-7-6'
select case when dateadd(yy,DATEDIFF(yy, @Birthday, GETDATE()),@Birthday)>getdate()
then DATEDIFF(yy, @Birthday, GETDATE())
else DATEDIFF(yy, @Birthday, GETDATE())+1
end