Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 根据SQL和C#中的出生日期计算年龄?_Sql Server_Sql Server 2005_C# 2.0 - Fatal编程技术网

Sql server 根据SQL和C#中的出生日期计算年龄?

Sql server 根据SQL和C#中的出生日期计算年龄?,sql-server,sql-server-2005,c#-2.0,Sql Server,Sql Server 2005,C# 2.0,可能的重复项: 如何根据客户的出生日期自动计算客户年龄 使用c#和SQLServer2005,我在谷歌上找到了这个:选择楼层(DATEDIFF(DAY,@BirthDate,@TargetDate)/365.25) 其中@TargetDate是今天的日期(GETDATE()在TSQL中) 祝你好运:)来自: 使用SQL函数。参见这一简单但不精确的方法。例如,1992年5月29日出生的人在2009年5月29日为17岁,但这个公式返回16岁。查看我的URL SELECT DATEDIFF(hou

可能的重复项:

如何根据客户的出生日期自动计算客户年龄
使用c#和SQLServer2005,我在谷歌上找到了这个:
选择楼层(DATEDIFF(DAY,@BirthDate,@TargetDate)/365.25)

其中@TargetDate是今天的日期(
GETDATE()
在TSQL中)

祝你好运:)

来自:


使用SQL函数。参见

这一简单但不精确的方法。例如,1992年5月29日出生的人在2009年5月29日为17岁,但这个公式返回16岁。查看我的URL
SELECT DATEDIFF(hour,@dob,GETDATE())/8766 AS AgeYearsIntTrunc