日期的语法错误 在查询表达式 'username='test'and yearmonth= #t1#' 中。
yearmonth= #yearmonth#
t1是个ASP里定义好的日期类型
yearmonth也是日期类型
应该怎么样写SQL语句
这个问题第1个回答:
把sql语句里的t1格式化为"yyyy-mm-dd"就行。
这个问题第2个回答:
但是我t1是个变量来的。。。。
这个问题第3个回答:
'username='test'and yearmonth= '"&t1&"'
这样就可以
这个问题第4个回答:
and 前少了空格
ACC数据库:
VBScript code
SQL = "select * from [TableName] where username='test' and yearmonth= #" & t1 & "#"
这个问题第5个回答:
用formatdatetime或者自己组合
"username='test'and yearmonth= #" & year(t1) & "-" & month(t1) & "-" & day(t1) & "#"
这个问题第6个回答:
where "username='test'and Convert(varchar(10),yearmonth,120)=Convert(varchar(10),'"+t1+"',120)