My explanation as following,Before year 20001994 will label as 941995 will label as 951996 will label as 961997 will label as 971998 will label as 981999 will label as 99declare @noKP as varchar(12)set @noKP='990308085777' -- my year of date of birth is 1999select case when convert(int,SUBSTRING(@noKP,0,3)) <= 99 then DATEPART(YEAR,GETDATE()) - Convert(int,'19' + SUBSTRING(@noKP,0,3)) else DATEPART(YEAR,GETDATE()) - Convert(int,'20' + SUBSTRING(@noKP,0,3)) end as myAge
After year 20002000 will label as 002001 will label as 012002 will label as 022003 will label as 032004 will label as 042005 will label as 05declare @noKP as varchar(12)set @noKP='010308085777' -- my year of date of birth is 2001select case when convert(int,SUBSTRING(@noKP,0,3)) <= 99 then DATEPART(YEAR,GETDATE()) - Convert(int,'19' + SUBSTRING(@noKP,0,3)) else DATEPART(YEAR,GETDATE()) - Convert(int,'20' + SUBSTRING(@noKP,0,3)) end as myAge
My calculation for after 2000 got problemNeed help to fixe and tune