怎样查询属于某天的记录(50分)

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

hhjjhhjj

Unregistered / Unconfirmed
GUEST, unregistred user!
SQL 中怎样查询属于某天的记录?表中有一字段(datetime)
 
Field >= :Date1 AND Field < :Date2
 
比如我要查询今天的记录,Date1 Date2 分别怎样写呢?
 
ADOQuery1.Parameters.ParamByName('Date1').Value := Date;
ADOQuery1.Parameters.ParamByName('Date2').Value := Date + 1;
 
FieldByName('Date1').asDateTime:=Now-1;
FieldByName('Date1').asDateTime:=Now;
 
Now-1 有点不科学哦。这样的话就是从昨天的这个时候到今天的这个时候的记录了!
 
楼上的那么写不行,那样包含的时间不正确,楼主最好用date类型,不要用datetime.
 
多人接受答案了。
 
后退
顶部