数据库是Access 字段f_date的数据类型是“日期/时间”,下面语句似乎不通过;(50分)

  • 主题发起人 西凉老猫
  • 开始时间
西

西凉老猫

Unregistered / Unconfirmed
GUEST, unregistred user!
select * from table where f_date='2002-07-25';
返回的错误是数据类型不匹配;
如果数据库是Sqlserver 2000,f_date 的数据类型是datetime,
那么上面的语句可以通过;
是不是access数据库的日期/时间类型字段后面有分钟和秒钟?那么如何才能实现
。。。。where f_date='2002-07-25';
 
可以使用 Like 关键字..
像这样:
SELECT * FROM table WHERE f_date LIKE '2002-07-25'
 
select * from table where f_date=strtodatetime('2002-07-25');
select * from table where f_date=strtodate('2002-07-25');
 
where f_date=:rq
parambyname('rq').asdatetime:=strtodate('2002-07-25');
 
同意使用参数形式
 
这样写可以:
select * from table where f_date=#2002-07-25#;
 
access数据库日期用#
select * from table where f_date=#2002-07-25#;
或者用动态参数吧
adoquery1.close;
adoquery1.sql.text:='select * from table where f_date=:f_date';
adoquery1.parameters.parambyname('f_date').value:='2002-07-25';
adoquery1.open;
 
楼上说的就是我就是这样的
 
在Access中,时间两边要加#号!
 
多人接受答案了。
 
顶部