How to calculate age in T-SQL with years, months, and days
问题 What would be the best way to calculate someone\'s age in years, months, and days in T-SQL (SQL Server 2000)? The datediff function doesn\'t handle year boundaries well, plus getting the months and days separate will be a bear. I know I can do it on the client side relatively easily, but I\'d like to have it done in my stored procedure. 回答1: Here is some T-SQL that gives you the number of years, months, and days since the day specified in @date. It takes into account the fact that DATEDIFF()