办法用尽,毫无效果,哪位大虾帮帮忙!

bibibi 2000-07-04 04:18:00
我用的是sql server(CollectTime是datetime类型)
date2=DateAdd("ww",-1,date)
sql="select Price,CollectTime from Price where collectTime='"&date2&"'"
报错:不能把char型转成datetime型
试过date2=formatdatetime(DateAdd("ww",-1,date1),vbLongTime)报同样的错
试过...where collecttime="&date2报错:语句未结束


...全文
291 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
zigzag 2000-07-05
  • 打赏
  • 举报
回复
sql="select Price,CollectTime from Price where datepart('yyyy',collectTime)="&datepart("yyyy",date2)&" and datepart('m',collectTime)="&datepart("m",date2)&" and datepart('d',collectTime)="&datepart("d",date2)
cjlong 2000-07-05
  • 打赏
  • 举报
回复
sql=sql+"where collectTime='"& "#" & date& "#" &"'"
应为
sql=sql &"where collectTime='"& "#" & date& "#" &"'"









cjlong 2000-07-05
  • 打赏
  • 举报
回复
简单:
date2=DateAdd("ww",-1,date)
dete3=cstr(date2)
sql="select Price,CollectTime from Price "
sql=sql+"where collectTime='"& "#" & date& "#" &"'"




imhere_l 2000-07-05
  • 打赏
  • 举报
回复
你的date2为日期型数据,直接和字符串相加当然会报错。可以转换为字符串类型后再相加就没有问题了
cjlong 2000-07-05
  • 打赏
  • 举报
回复
细心看他与where collecttime=#"&date2&"# 的区别。
cjlong 2000-07-05
  • 打赏
  • 举报
回复
我以调试通过,再试!!
date2=DateAdd("ww",-1,date)
dete3=cstr(date2)
sql="select Price,CollectTime from Price "
sql=sql & "where collectTime='"& "#" & date3 & "#" &"'"





bibibi 2000-07-05
  • 打赏
  • 举报
回复
都试过了,还是报同样的错:can not convert datetime from char。
5555555555???????!!!!!!!!!
Tyro 2000-07-04
  • 打赏
  • 举报
回复
试试:
sql="select Price,CollectTime from Price where collectTime='" &
cstr(date2) & "'"
linyu 2000-07-04
  • 打赏
  • 举报
回复
你能不能显示sql出来看一下。
response.write sql
然后再运行。
帖出来。。。
Un1 2000-07-04
  • 打赏
  • 举报
回复
sql="select Price,CollectTime from Price where collectTime=" & date2
如何?
bibibi 2000-07-04
  • 打赏
  • 举报
回复
“ 与 & 之间的空格加了,可还是抱同样的错。
另外,我还试了用where collecttime=#"&date2&"#。报错:符号#发生错误
谁能告诉我到底这个datetime怎么回事。。。。
leslielu 2000-07-04
  • 打赏
  • 举报
回复
再试试formatdatetime(DateAdd("ww",-1,date1),vbshorttime)
另外注意 “ 与 & 之间的空格一定要有

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧