30 Jan 2013

Calculate Age in SQL

FLOOR((CAST(CONVERT(VARCHAR(8),@TodaysDate,112) AS INT)-CAST(CONVERT(VARCHAR(8),@DOB,112) AS INT) ) / 10000)

This script calculate age using date of birth.
Tested in MS SQL 2008

0 comments:

Post a Comment