4 回答
TA贡献1824条经验 获得超6个赞
sql server的话就下面了
select
* from testDate
where
substring(convert(varchar(100),birthdate,112),5,4)
between substring(convert(varchar(100),getDate(),112),5,4) and
substring(convert(varchar(100), DATEADD(d,2, getDate()),112),5,4)
要是想处理2月29日的人的话。就用in吧
select
* from testDate
where
substring(convert(varchar(100),birthdate,112),5,4)
in(substring(convert(varchar(100),getDate(),112),5,4),
substring(convert(varchar(100), DATEADD(d,1, getDate()),112),5,4),
substring(convert(varchar(100), DATEADD(d,2, getDate()),112),5,4))
TA贡献1773条经验 获得超3个赞
第一种:month(colname)=month(getdate()) and day(colname)-day(getdate()) between 0 and 2
第二种:datediff(day,convert(datetime,str(year(getdate()),4)+'-'+str(month(requireddate),2)+'-'+str(day(requireddate),2)),requireddate) between 0 and 2
暂时就想到这2种,还有的lx可以添加。
- 4 回答
- 0 关注
- 654 浏览
添加回答
举报