VB SQL过期日期查询--高分

来源:百度知道 编辑:UC知道 时间:2024/09/28 15:43:13
把当前日期与数据库中(过期日期)字段.大于30天的纪录显示出来.

语言:VB6
数据库:sql server2000

select *
from 表
where datetime>now()+30

a=year(date)
b=month(date)
c=day(date)
c=c-30
if c<1 then
if b=12 or b=3 or b=5 or b=7 or b=8 or b=10 then
b=b-1
c=31+c
elseif b=4 or b=6 or b=9 or b=11 then
b=b-1
c=30+c
elseif b=2 then
b=b-1
if a mod 4 =0 then
c=29+c
else
c=28+c
end if
elseif b=1 then
a=a-1
b=12
c=31+c
end if
else
c=c-30
end if
x= CDate(a & "-" & b & "-" & c)
strSQL="Select * from 数据表名 Where 日期<'" & x & "'" Access数据库或
strSQL="Select * from 数据表名 Where 日期<" & x & "" SQL数据库

把时期加上30天,不就行了

select *
from 表
where datetime < now()-30

select *
from 表
where datetime < (now()-30)

试试,我复制上面的来改的