sql - Coding function calculate age from a DOB -


i trying populate field in table calling following function calculate person's age dob. when execute code receive following error:

the error incorrect syntax near keyword 'end'

i don't know why? please help.

create function findage (@dateofbirth date) returns int begin return (floor(datediff(year,@dateofbirth, getdate())) end 

create function findage (@dateofbirth date) returns int begin   declare @age int;    set @age = floor(datediff(year,@dateofbirth, getdate()));   return @age; end 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -