indate为数据库中字段,为日期型;我把DateTimePicker1.Date转换为字符型后进行比较提示‘表达式中数据类型不匹配’ 请高手们看一下下面的语句该怎么写?
小弟不胜感激。
LODM.ADOQgoodsin.SQL.Text:='select * from googdsininf where indate >'''+DateToStr(DateTimePicker1.Date)+'''';

解决方案 »

  1.   

    'select * from googdsininf where indate>to_DATE(:indate,''yyyy-mm-dd''')';
    Params.ParamValues['indate']:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date);
      

  2.   

    LODM.ADOQgoodsin.SQL.Text:='select * from googdsininf where indate >'''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''';
      

  3.   

    LODM.ADOQgoodsin.SQL.Text:='select * from googdsininf where indate >'''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''';要不就用参数
      

  4.   

    LODM.ADOQgoodsin.SQL.Text:='select * from googdsininf where indate > :setDatee
    //指定参数类型
    LODM.ADOQgoodsin.parameter.paramByName('setDate').DataType := ftDate;    
    //参数赋值
    LODM.ADOQgoodsin.parameter.paramByName('setDate').value := DateTimePicker1.Date;
    就好了。
      

  5.   

    DateTimeToStr,StrToDateTime,StrToDate,StrToTime是根据系统设置的格式进行转换的。