由于我的表AAA中采用字符型字段Opdate来记录某天的日期,我想读取表中Opdate小于今日日期的所有记录,不知如何写啊???
不能用下面的方法,因为此法会导致 2003-9-8 > 2003-10-4 的错误。
SQL.text:='select * from AAA where  Opdate<:pdate;
Parameters.ParamValues['Pdate']:=FormatDateTime( 'YYYY-M-D',date);

解决方案 »

  1.   

    SQL.text='select* from AAA where  '+strtodate(Opdate)+……
    就是把字符串型加起来吗,后面的自己写了
      

  2.   

    to  angle097113(深思不解)
    datediff()是什么函数?怎么用?to   vavyboyleon(一天到晚加班的驴) 
    你好像没理解我的意思吧!
      

  3.   

    哎自找麻烦,你把AAA改成datetime型什么问题都没了!有更好的类型你不用!自寻烦恼啊!datediff()在SQL的HELP里面找(MS SQL SERVER 2000中自带)!
      

  4.   

    'select* from AAA where strtodate(opdate,'yyyy-mm-dd')
      

  5.   

    to  rocktan(我是一条狗) 
    你的方法不行的。
    没人能解决?!#¥%……
      

  6.   

    再试一下这个看看
    SQL.text:='select * from AAA where '+StrToDate('+Opdate+')<:pdate';
    Parameters[0]:=Date;
    另外:
     1、日期用DateTime型就行了,别用字符型
     2、DateDiff(DatePart,date1,Date2) 这个函数是返回Date1、Date2间的时间间隔,其单位是由datepart参数指定
      

  7.   

    如果在DELPHI里用的脚本可以这样写:
    1.
    SQL.text='select* from AAA where  date=' +vdate 
    date: 字段日期型
    vdate :在DELPHi 里的日期型日期
    2.
    SQL.text='select* from AAA where  date2=' +datetostr(vdate2) 
    date: 字段字符型
    vdate :在DELPHi 里的日期型日期
    3.
    如果是oracle 数据库 可以直接把字符型转换成日期型,用函数:to_date('yyyy-mm-dd','2003-10-09')
      

  8.   

    2、DateDiff(DatePart,date1,Date2) 这个函数是返回Date1、Date2间的时间间隔,其单位是由datepart参数指定
      

  9.   

     是否为 ACCESS 数据库 要加 “#2003-10-10#”   ?
      

  10.   

    首先多谢各位的帮助。
    to  ltmb118() 
    我是用access数据库的,怎么加“#2003-10-10#”