香港资生堂专柜地址:SQL语句提取今天的数据,ASP的问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 18:30:58
我的是SQL数据库,之前是ACCESS

说明:reg_date在SQL数据库字段属性是:smalldatetime
注册提交ASp写入数据:rs("reg_date")=date()

在ACCESS数据库下执行下面的语句没问题
rs.open "select * from f_user where reg_date=date() order by user_id desc",conn,1,1

但是在SQL数据库下
rs.open "select * from f_user where reg_date=date() order by user_id desc",conn,1,1
这条语句不能读取当日数据!

求正确写法

当然不能读取了,因为你的用法是asp里面的
而你的写法是把他Date()作为sql语句了

正确的写法是正常把他作为变量写入字符串

rs.open "select * from f_user where reg_date='"&date()&"' order by user_id desc",conn,1,1

select * from f_user where reg_date=date() order by user_id desc
把前面的和后面的都去掉

rs.open "select * from f_user where reg_date=getdate() order by user_id desc",conn,1,1
或者
rs.open "select * from f_user where reg_date=#"date()"# order by user_id desc",conn,1,1

是不是可以把当天的日期先赋值给一个变量