急!! asp 取 access数据库中记录问题

sunlarry 2003-10-17 10:52:04
有表ttt,其中有两个时间字段instertdate1 ,instertdate2
现有一时间2003-12-20, sql语句如下:
select * from ttt where instertdate1 >2003-12-20 and insertdate2 <2003-12-20

按上述方法取不到数据记录,但是数据库中确实有2003-12-20属于instertdate1 和 instertdate1 之间的记录

请高手指点...
...全文
32 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwliaole 2003-10-17
  • 打赏
  • 举报
回复
在Aceess中日期型字段前应该加#.

select * from ttt where instertdate1 >#2003-12-20# and insertdate2 <#2003-12-20#
zhaoliangpat 2003-10-17
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2132/2132876.xml?temp=.8201563
yangyanggood 2003-10-17
  • 打赏
  • 举报
回复
我来帮楼主顶了!
sunlarry 2003-10-17
  • 打赏
  • 举报
回复
如果时间加单引号运行后报错如下:
错误类型:
Microsoft JET Database Engine (0x80040E07)
标准表达式中数据类型不匹配。
/test.asp, 第 16 行

如果不加单引号不报错,但无法查出正确记录
sunlarry 2003-10-17
  • 打赏
  • 举报
回复
to lihua9666(木子华)

可以这样写吗, 不可能吧! 我试了,不行呀!

这个在SQL SERVER下可以运行成功,但在access下确有错!!

老大们来呀,急
lihua9666 2003-10-17
  • 打赏
  • 举报
回复
select * from ttt where instertdate1 >='2003-12-20 and' insertdate2 <='2003-12-20'
lihua9666 2003-10-17
  • 打赏
  • 举报
回复
select * from ttt where instertdate1 >='2003-12-20 and' insertdate2 <='2003-12-20'
sunlarry 2003-10-17
  • 打赏
  • 举报
回复
to : Brookes(边走边唱)

这样写就报错呀, 数据类型不匹配!

按我的写法不报错,但无法查出正确记录
Brookes 2003-10-17
  • 打赏
  • 举报
回复
select * from ttt where instertdate1 >'2003-12-20' and insertdate2 <'2003-12-20'
myfc 2003-10-17
  • 打赏
  • 举报
回复
select * from ttt where instertdate1 >='2003-12-20' and insertdate2 <='2003-12-20'
哦!应该是这样!
myfc 2003-10-17
  • 打赏
  • 举报
回复
select * from ttt where instertdate1 >='2003-12-20 and' insertdate2 <='2003-12-20'
绝对没有问题!测试过的
sunlarry 2003-10-17
  • 打赏
  • 举报
回复
是可以执行呀, 但是查不出记录集,但是数据库中是有该记录的
stefli 2003-10-17
  • 打赏
  • 举报
回复
Aceess中使用#
select * from ttt where instertdate1 >#2003-12-20# and insertdate2 <#2003-12-20#


sql中使用'
select * from ttt where instertdate1 >'2003-12-20' and insertdate2 <'2003-12-20'

注意区分使用

28,390

社区成员

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

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