CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  VCL组件开发及应用

如何查询数据库中某一时间段内的数据?各位前辈,小第初学,多指教。

楼主fishp(黄海小鱼)2002-12-04 23:45:27 在 Delphi / VCL组件开发及应用 提问

各位大哥,小弟现在练习的程序有个功能是查询某一时间段内的数据,同样的  
  一句语句select   *   from   attendance   where   io_time>'2002-11-01'   and   io_time<'2002-12-04'  
  在SQL   SERVER查询分析器里执行能找到符合条件的记录,而在  
  with   DM_main.query1   do  
                      begin  
                      close;  
                      sql.clear;  
  sql.add('select   *   from   attendance   where   io_time>'2002-11-01'   and   io_time<'2002-12-04'');  
                      prepare;  
                      open;  
                      end;  
  里,执行时,却提示  
  Error]   u_attendance.pas(307):   Missing   operator   or   semicolon  
  [Error]   u_attendance.pas(307):   Missing   operator   or   semicolon  
  [Error]   u_attendance.pas(307):   Incompatible   types:   'String'   and   'Integer'  
  [Fatal   Error]   attendance.dpr(11):   Could   not   compile   used   unit   'u_attendance.pas'  
  307行是sql.add('select   *   from   attendance   where   io_time>'2002-11-01'   and   io_time<'2002-12-04'');io_time是datetime型的  
  请问是什么原因?  
          谢谢了! 问题点数:20、回复次数:4Top

1 楼xgqing(xgqing)回复于 2002-12-04 23:50:22 得分 10

改为sql.add('select   *   from   attendance   where   io_time>''2002-11-01''   and   io_time<''2002-12-04''')Top

2 楼DunDao(所有这一切都是会有报应的)回复于 2002-12-04 23:51:11 得分 5

sql.add('select   *   from   attendance   where   io_time>''2002-11-01''   and   io_time<''2002-12-04''');Top

3 楼filix(传说中的卷心菜)回复于 2002-12-05 02:53:29 得分 5

query里面''''代表‘,你的语句应该改成  
  sql.add('select   *   from   attendance   where   io_time>'+''''+'2002-11-01'+''''+'   and   io_time<'+''''+'2002-12-04'+'''');  
  这样的sql语句才是  
  select   *   from   attendance   where   io_time>'2002-11-01'   and   io_time<'2002-12-04'Top

4 楼nightroad(一年)回复于 2002-12-05 08:50:51 得分 0

sql.add('select   *   from   attendance   where   io_time>'+#39+2002-11-01+#39+'   and'+'   io_time<'+#39+2002-12-04+#39);Top

相关问题

  • 各位前辈,我在数据库中有一个字段io-time是datetime类型的,我如何查询数据库中某一时间段内的数据?
  • 如何恢复数据库到某一时间点?急啊,在线等待!
  • 请较如何导出数据库中某一时间段的数据
  • 大家能不能总结一下,某一时间段内数据库记录的查询方法?
  • 初学vb.net 希望各位前辈给个用vb.net所写读写数据库的组件的例子
  • 数据库的初学问题
  • 初学者提问,数据库问题
  • 初学者连数据库问题
  • 初学数据库,请各位前辈推荐一下比较好的关于DELPHI SQL编程的书籍,谢谢!
  • 本人初学数据库! 哪为高手能帮我做一个数据库!

关键词

  • 查询
  • 数据
  • 某一时间
  • 段内的数据
  • time
  • and io

得分解答快速导航

  • 帖主:fishp
  • xgqing
  • DunDao
  • filix

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo