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

April 5, 2001

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


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

The Network for Technology Professionals


About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers