AQOQuery.sql.add('select * from 档案 where 工号='''+edit1.text+''' and  (now()-参加工作时间)>30 ') ;
后面的AND 语句该怎么写,有什么格式?其中工号、参加工作时间(日期型)都是档案表的字段。
  象前面的edit要在前后加“+”号和“’”,费了好大的劲才知道,哪里有这方面的知识。
 用的是ORACLE数据库,ADO连接。

解决方案 »

  1.   

    'select * from 档案 where 工号='+edit1.text+' and '
    +datetimetostr (now()-参加工作时间)>30 '
      

  2.   

    sorry!写错啦!这里面还得用到数据厍函数!我这里现在用的是oracle函数。
    'select * from 档案 where 工号='+edit1.text+' and '+'to_date('+''''
    +formatedate('yyyymmdd',now)+''''+','+''''+'yyyymmdd'+''''+')'+
    '-参加工作时间)>30 '
    这个to_date是oracle函数,formatedate是delphi函数具体参数查资料!
      

  3.   

    'select * from 档案 where 工号='+edit1.text+' and '
    +datetimetostr (now()-参加工作时间)>30 '
    执行后是这个结果,再帮忙看看。

    [Error] Unit1.pas(64): Illegal character in input file: '出' ($B3F6)
    [Error] Unit1.pas(66): Incompatible types: 'String' and 'Boolean'
    [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
      

  4.   

    我再试试,谢谢pingshx() ;
      

  5.   

    你可以直接用sql的当前时间啦
    不一定要用delphi自带的now
      

  6.   

    谢谢 tanlijun37(tlj) ,问题已解决。