以日期作为主键时查询的问题(200)

S

shijie

Unregistered / Unconfirmed
GUEST, unregistred user!
这样对不对?有没有其他的办法?begin with SQLQuery1 do begin close; SQL.Clear; SQL.Add('Select * from 表名 where 时间>:a and 时间 <:b'); Params.ParamByName('a').Value:=Trunc(DateTimePicker1.Date); Params.ParamByName('b').Value:=Trunc(DateTimePicker1.Date)+1; Open; end; if SQLQuery1.RecordCount>0 then ...//代码省略
 
SQL.Text:='Select * from 表名 where 时间 > '+''+tatetostr(DateTimePicker1.Date)+''''+' and 时间 < '+''+tatetostr(DateTimePicker2.Date+1)+'''';如果是ACCESS 数据库用 # 号代替SQL.Text:='Select * from 表名 where 时间 > #'+tatetostr(DateTimePicker1.Date)+' # and 时间 < #'+tatetostr(DateTimePicker2.Date+1)+'#';
 
顶部