蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

[asp]关于日期格式转换方面的问题

以下所指的操作符是什么?

语法错误 (操作符丢失) 在查询表达式 'recorddate '2005-8-10' between '2005-8-21'' 中。

出错处SQL语句

    SQLstr="SELECT * FROM my_table WHERE "
    SQLstr=SQLstr&"tabledate '"&date1&"' between '"&date2&"'  ORDER BY tabledate DESC"
    rs.open SQLstr,ConnStr,3

背景是:我从表单选择下拉菜单内的数字,查询2005-8-10到2005-8-21之间的数据,接到表单传递的数字字符串,我用以下的方法转换为日期的格式;
    date11=cint(request.form("date11"))
    date12=cint(request.form("date12"))
    date13=cint(request.form("date13"))
    if date11<>"" and date12<>"" and date13<>"" then
      date1=dateserial(date11,date12,date13)
    end if

    date21=cint(request.form("date21"))
    date22=cint(request.form("date22"))
    date23=cint(request.form("date23"))
    if date21<>"" and date22<>"" and date23<>"" then
      date2=dateserial(date21,date22,date23)
    end if
我是哪里做错了,这样转换为日期格式对吗?请教各位高手,已经3天了,我实在不知道怎么办了。

正确的sql语句是
[code]
where recorddate between '2005-06-09' and '2005-09-01'[/code]

SQLstr=SQLstr&"tabledate '"&date1&"' between '"&date2&"' ORDER BY tabledate DESC"
改成
SQLstr=SQLstr&"tabledate between #"&date1&"# and #"&date2&"# ORDER BY tabledate DESC" 试试看,这个是时间的格式!

哦,谢谢2位,原来是SQL语句写错了,我还以为是我的脚本有错呢,明天试试看

小弟最近急死了。后缀为asp的文件须用什么工具将其打开呀 ?请各位大师们请教啊。

long725920在上个帖子中说

用你的开发工具
或者是notepad




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com