adoquery1.sql.add('select * from [user] where 出生日期>=)'+#39+DateTostr(Date)+#39+' and 出生日期<='+#39+DateTostr(Date+15)+#39)
select * from user where bortDate> dateadd(day,-15,getdate())
to SiTwo(闻之笑) #39 代表是什么意思?
adoquery1.sql.text:='select * from user where ' +'(DATEPART(month,getdate()+15)=DATEPART(month,bortDate)) and (' +''DATEPART(day,getdate()+15)=DATEPART(day,bortDate))'
select * from @T where (case when (birthday>convert(varchar(10),getdate(),120)) then datediff(day,convert(varchar(10),getdate()),birthday) else datediff(day,birthday,convert(varchar(10),getdate(),120)) end)<=15
declare @T table (name varchar(20),birthday datetime) insert into @T select '张三','1977-08-18' union all select '李四','1982-10-12' union all select '王五','1985-12-15'--上面建立测试表 select * from @T where (case when (birthday>convert(varchar(10),getdate(),120)) then datediff(day,convert(varchar(10),getdate()),birthday) else datediff(day,birthday,convert(varchar(10),getdate(),120)) end)<=15
select * from user where bortDate> dateadd(day,-15,getdate()) and bortDate< dateadd(day,15,getdate())
select * from user where datediff(day, getdate(), bortDate) <= 15
where bortDate> dateadd(day,-15,getdate())
#39 代表是什么意思?
+'(DATEPART(month,getdate()+15)=DATEPART(month,bortDate)) and ('
+''DATEPART(day,getdate()+15)=DATEPART(day,bortDate))'
where (case when (birthday>convert(varchar(10),getdate(),120))
then datediff(day,convert(varchar(10),getdate()),birthday)
else datediff(day,birthday,convert(varchar(10),getdate(),120))
end)<=15
insert into @T
select
'张三','1977-08-18'
union all
select
'李四','1982-10-12'
union all
select
'王五','1985-12-15'--上面建立测试表
select * from @T
where (case when (birthday>convert(varchar(10),getdate(),120))
then datediff(day,convert(varchar(10),getdate()),birthday)
else datediff(day,birthday,convert(varchar(10),getdate(),120))
end)<=15
where bortDate> dateadd(day,-15,getdate()) and bortDate< dateadd(day,15,getdate())
where datediff(day, getdate(), bortDate) <= 15