SQL 2000 UDF to return the age of a person, given a date of birth

Thursday Apr 5th 2001 by Karl Granbow
Share:

SQL Server 2000 script for creating a user defined function that returns the age of person whose date of birth has been provided.

To use the function:

SELECT dbname.dbo.GetAge(DateOfBirth, GETDATE()), column1, column2....,
FROM TableName

Alternatively

SELECT * FROM TableName
WHERE dbname.dbo.GetAge(DateOfBirth, GETDATE()) > n

Unfortunately SQL Server 2000 doesn't allow for the use of GETDATE() within user defined functions so it needs to be passed explicitly as a parameter.

Get the Script

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved