100分请教Delphi下Access数据库的时间查询!(100分)

  • 主题发起人 主题发起人 hedana1977
  • 开始时间 开始时间
H

hedana1977

Unregistered / Unconfirmed
GUEST, unregistred user!
var
ctime1,ctime2:string;
begin
ctime1:=formatdatetime('yyyymmdd',time1.Date);
ctime2:=formatdatetime('yyyymmdd',time2.Date);

if cgk.Active then cgk.Close ;
cgk.CommandText :='select * from v_cgk where convert(char,cgdate,112)>='+''''+ctime1+''''+' and convert(char,cgdate,112)<=' +''''+ctime2+'''';
cgk.Open ;
end;

我这个上面是SQL server数据库下的,但是Access下,不能用,好像是没有convert
这个函数,请教高手我应该怎么写,谢谢。
 
cgk.CommandText := format(
'select * from v_cgk where cgdate between #%s# and #%s#',
[DateToStr(time1.Date)
,DateToStr(time2.Date)]);
 
谢谢肥羊,问题已经解决了,方法很好!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部