- Code: Select all
select year(getdate())
- year(DOB)
- case when month(DOB) > month(getdate()) then 1
when month(DOB) < month(getdate()) then 0
when day(DOB) > day(DOB) then 1
else 0
end as age
from HR
select year(getdate())
- year(DOB)
- case when month(DOB) > month(getdate()) then 1
when month(DOB) < month(getdate()) then 0
when day(DOB) > day(DOB) then 1
else 0
end as age
from HR Return to Database ( MSSQL, MYSQL, Oracle)
Users browsing this forum: No registered users and 0 guests