Calculating age based on date of birth in SQL and C#?
Possible Duplicates:
How to calculate age (in years) based on Date of Birth and getDate()
How do I calculate someone's age in C#?
How to calculate the customer age automatically by using their Date of Birth using c# and SQL Server 2005
从这里:
SELECT DATEDIFF(hour,@dob,GETDATE())/8766 AS AgeYearsIntTrunc
I found this on Google: SELECT FLOOR(DATEDIFF(DAY, @BirthDate, @TargetDate) / 365.25)
Where @TargetDate is the date of today ( GETDATE()
in TSQL).
Good luck :)
Use a SQL function. See http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/399a7e87-bc78-47a5-8cc2-2d2436886fd7/
链接地址: http://www.djcxy.com/p/54362.html上一篇: 精确的年龄计算
下一篇: 在SQL和C#中基于出生日期计算年龄?