Finding someone's age in SQL

前端 未结 7 2341
孤街浪徒
孤街浪徒 2020-12-16 21:11

In a SQL Server database, I record people\'s date of birth. Is there an straight-forward method of working out the person\'s age on a given date using SQL only?

Usi

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 21:58

    SELECT Pname, DOB, DATEDIFF(YEAR, DOB, GETDATE()) AS Age
    FROM tablename
    

提交回复
热议问题