Tuesday, 25 March 2014

Find Age from Date of Birth in Sql Server


declare @dob datetime = '1952-08-14 21:11:19.300'

select CAST( DATEDIFF(Y , @dob , getdate() )/365.25 as int)

-- 365 are the Number of Average days in 4 years


No comments:

Post a Comment