sql="select DISTINCT date from table where 日期字段>=#2002-06-01 # and 日期字段<=#2004-11-1#" order by date 选出这期间所有的数据按日期排序
rs.open sql,conn,1,1
str=""
str1="2004-6-1" 开始日期
do while not rs.eof
num=datediff("d",'"&str1&"','"&rs(date)&"')'得出日期差
if num>0 then
for i=1 to num
str=str&(str1)&"@"
next
end if
str1=rs(date)
rs.movenext
loop
我认为ghostzp总体的思路不错,但还要注意一点,就是说他的记录中有多条日期相同的,应该使用DISTINCT来取唯一值,即每一个语句改为:
sql="select distinct 日期字段 from table where 日期字段>=#2002-06-01# and 日期字段<=#2004-11-1#"
应该有可以了
楼主说只有八千多条记录的话,应该是几秒钟就搞定了。
sql="select * from table where 日期字段>=#2002-06-01 # and 日期字段<=#2004-11-1#" 选出这期间所有的数据
rs.open sql,conn,1,1
str=""
do while not rs.eof
str=str&rs("日期字段")&"," '把所有得日期字段串成一个字串,你要确定你的日期格式统一
rs.movenext
loop
num=datediff("d","2004-6-1","2004-11-1")'得出日期差
for i=1 to num
tmp=dateadd("d",i,"2004-6-1")
if instr(str,tmp)<0 then '不存在这个日期
response.write tmp &"<br>"
end if
next
只能用循环,假设数据库中有个最简单的字段如id,用count(id)可以减少返回的数据,
k=datediff("d",cdate("2002-6-1 00:00:00"),cdate("2004-11-1 00:00:00"))
d=cdate("2002-6-1 00:00:00")
for i=0 to k-1
sql="select count(id) from table where [date] between '"&d&"' and '"&d+1&"'"
rs.open sql,conn,3,1
if rs(0)=0 then
response.write d&"没有数据"
end if
d:= d+1
next