【发布时间】:2016-10-11 10:25:33
【问题描述】:
我是 SQL 新手,我正在尝试从某个日期范围内提取数据。就我而言,我想要一周前的数据。我正在努力争取上周年满 13 岁的客户,但我的 between 条款不起作用。有什么建议吗?
select distinct [Account Number], [Date of Birth], [Age in Years]
from adhoc.[Patient Demographics]
where [Age in Years] = 13 and between datepart(dd,getdate()) and datepart(dd,getdate()-7)
列是:
PracName (varchar(95), null)
Patient ID(int, not null)
Account number (varchar(15), null)
Title (varchar(50), null
First Name (Varchar(95), not null)
Middle Name (varchar(95), not null)
Last Name (varchare(95), not null)
Gender (varchar(1), null
Date of Birth(datetime, null)
Age in Years(int, null)
Age in Months (int, null)
Age in Weeks (int, null)
Age in Days (int, null)
Age in UDS (int, null)
Age Group (varchare(7), no null)
【问题讨论】:
标签: sql tsql between date-range datepart