从一列dob中确定年龄组 [英] Determining age group from a column of dob's

查看:73
本文介绍了从一列dob中确定年龄组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好 - 我的DataWarehouse中有一个名为dbo.Full Roster的数据库。在运行查询以打开它之后,我得到一个包含标题的表,来源,付款人,患者,dob,性别,地址等。在dob列下,出生日期格式为例如:1963年3月9日上午12点00分,1936年9月24日上午12点,1961年1月21日上午12点00分,1952年8月29日上午12:00,等等。我很感激任何有关快速代码或查询的帮助,可以捕获50至75岁年龄组内的所有患者。非常感谢你。 Sikaman

解决方案

假设,DOB是日期列,尝试这样的事情:

  SELECT  *  FROM  Table_Name  WHERE  datediff(year,dob,getdate ())   50    75  


Hi anyone - I have a database in my DataWarehouse called "dbo.Full Roster". After running a query to open this I get a table with headers, "source", "payer", "patient", "dob", "gender", "addr", etc. Under the dob column are date of births formatted as such: Mar 9 1963 12:00AM, Sep 24 1936 12:00AM, Jan 21 1961 12:00AM, Aug 29 1952 12:00AM, and so forth. I would appreciate any help with a quick code or query that can capture all patients within the age group 50 to 75 years of age. Thank you kindly. Sikaman

解决方案

Assuming, DOB is date column, try something like this:

SELECT * FROM Table_Name WHERE datediff(year,dob,getdate()) between 50 and 75


这篇关于从一列dob中确定年龄组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆