注册 登录
编程论坛 ASP技术论坛

asp access输出问题

s441987276 发布于 2013-11-04 23:21, 645 次点击
dim year
    dim month
    year=Request.Form("nowYear")
    month=Request.Form("month")        

    Set rs=Server.CreateObject("ADODB.RecordSet")
sql="select ygxm,ksrq,title,carhm,carzt from carzy where carhm <> '萧山机房' and (ksrq  >= #"&year&"-"&month&"-1# and ksrq < #"&year&"-"&(month+1)&"-01#)  order by ygxm"
 
    rs.Open sql,conn,1,2
    rs.update
    Set fs = server.CreateObject("scripting.filesystemobject")
    filename = Server.MapPath("tongji.xls")
    if fs.FileExists(filename) then
    fs.DeleteFile(filename)
    end if

    set myfile = fs.CreateTextFile(filename,true)

    if rs.EOF and rs.BOF then

怎么只能一直下载第一次查询出来那个月的数据? 还不知道屏蔽掉‘萧山机房’?求高手解答
6 回复
#2
yms1232013-11-05 09:33
sql="select ygxm,ksrq,title,carhm,carzt from carzy where carhm <> '萧山机房' and (ksrq  >= #"&year&"-"&month&"-1# and ksrq < #"&year&"-"&(month+1)&"-01#)  order by ygxm"
时间查询最好用DateDiff函数,不要直接比大小
#3
s4419872762013-11-05 10:13
回复 2楼 yms123
能帮忙写个datediff程序吗?刚学还不懂。谢谢
#4
yms1232013-11-05 10:20
DateDiff就是3个参数
一个按什么比较,
另外两个是时间参数
百度的解释
DATEDIF函数_百度百科 http://baike.baidu.com/link?url=-r0EEFTy4xT-qYLglni6nUTGl9SNnvGGvq-dQ8kIfooHiBEjnagIyY82ejVDnLU7YeeSVUjXwbDt8a43OX04La
#5
s4419872762013-11-05 10:38
回复 4楼 yms123
看着不是很懂。。这个是算时间差的结果吧。。我要的是时间差中所有的数据。。
#6
maprincesse2013-11-05 18:01
用between and好一些吧 时间不能直接比较大小的
#7
非阁楼似雪飞2013-11-11 17:07
同上,时间最好不要直接比大写,用上面网友说的时间函数来解决这类问题,要更精确一些
1