我建了个表,里面有个列是‘建表时间’属性为datetime,我现在想以系统当前时间(日期,不含时间)为搜索对象对表中的记录进行搜索,请问我该怎么写这个语句?adodataset1.Active:=false;
     adodataset1.CommandText:='select * from 员工考勤表 where 编号='+Edit1.Text+'';
     ADODataSet1.Active:=true;以上是我以编号为对象进行的记录搜索,如果改为以当前时间为对象进行记录搜索该怎么写语句?

解决方案 »

  1.   

    Delphi中有Date, Now等函数。
    数据库中也有GetDate()等函数。
      

  2.   

    'select * from 员工考勤表 where 建表时间='''+formatdatatime('yyyy-mm-dd',now())+''''关键是你的format要和数据库中的日期格式一致,我试过的,没问题
      

  3.   

    sql server
      strSQL := 'select * from 员工考勤表 where 建表时间='''+FormatDateTime(Date(),'yyyy-mm-dd')+'''';
    access
      strSQL := 'select * from 员工考勤表 where 建表时间=#'+FormatDateTime(Date(),'yyyy-mm-dd')+'#';