在dephi中的要比较日期类型的数据,应该用什么格式?
比如:
要查找日期为2005-10-12日的数据
sql.add('select * from table where 日期='?'');
'?'处应该用什么格式写出要比较的日期?

解决方案 »

  1.   

    sql.add('select * from table where 日期=:xDate');
    Parameters[0].Value:=StrToDate(Edit1.Text);
    Open;
      

  2.   

    Paradox:
      'select * from aa where (EnterTime>='+''''+FormatDateTime('mm',EnterTimeDTP.DateTime)+
                '/'+FormatDateTime('dd',EnterTimeDTP.DateTime)+'/'+FormatDateTime('yyyy',EnterTimeDTP.DateTime)+
                ' 00:00:00:00'+''''+') ';
    Access:
    decodeDate(DateTimePicker1.DateTime,yyyy,mm,dd);
         tempsql:='select * from aa where 日期 Between '+'#'+inttostr(mm)+'/'+inttostr(dd)+'/'+inttostr(yyyy)+'# And ';
         decodeDate(DateTimePicker2.DateTime,yyyy,mm,dd);
         tempsql:=tempsql+'#'+inttostr(mm)+'/'+inttostr(dd)+'/'+inttostr(yyyy)+'#')