Hi,
I want to calcute the diffence between current date and the date a person is born in year.
Birthday is stored in a column with vachar(12).
I try this SQL statement:
SELECT CONVERT(DATETIME,LEFT(birthdate,8),120), DATEDIFF(YEAR,CONVERT(DATETIME,LEFT(birthdate,8),120),getdate()) as 'Age' from Person
The funny thing with this SQL is if a person is born 201809234247 (social security number) and the current date is 2019-02-22 the age result will be 1 year. This is not true - it should be 0.
Something is wrong with my SQL statement but what?

Madan ShekarRank #428 · 5.9K reputationPosted Feb 22, 2019, 1:55 AM EST
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 25, 2019, 1:08 AM EST
Ishan Shah97 reputationPosted Mar 27, 2019, 2:50 AM EDT
Suraj KumarRank #353 · 7.1K reputationPosted Feb 24, 2019, 11:18 PM EST