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
Post a Comment