USERID Vendors dob(Year) login 1 yes 1985 yes 2 yes 1961 yes
USERID Vendors dob(Year) login Age 1 yes 1985 yes 34 2 yes 1961 yes 59
SELECT dob(Year) ,GETDATE() AS (Today) ,DATEDIFF (YY, dob(Year),GETDATE()) - CASE WHEN DATEADD(YY,DATEDIFF(YY,dob(Year),GETDATE()), dob(Year) > GETDATE () THEN 1 ELSE 0 END AS (AGE) from table
Year()
SELECT CurrentYear = Year(GetDate())
SELECT *, Age = Year(GetDate()) - [dob(year)];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)