这是Oracle的写法select * from jiben_account 
  where strtodate(kaihui_date) between t1.date and t2.date
union
select * from yiban_account
  where strtodate(kaihui_date) between t1.date and t2.date
union
select * from temp_account
  where strtodate(kaihui_date) between t1.date and t2.date
union
select * from zuanyong_account
  where strtodate(kaihui_date) between t1.date and t2.date
union
select * from qita_account
  where strtodate(kaihui_date) between t1.date and t2.date

解决方案 »

  1.   

    继续报错
    invalid use of keyword
    token:date
    怎么回事?
      

  2.   

    add('select * from jiben_account,yiban_account,temp_account,zuanyong_account,qita_account');add(' where :param1<=:param2 and :param3>=:param4') ;
    Query2.params[0].asdate:=t1.date;
    Query2.params[1].asdate:=StrToDate(kaihui_date);
    Query2.params[2].asdate:=t2.date;
    Query2.params[3].asdate:=StrToDate(kaihui_date);where前应该有一个空格,用单引号引起来的被认为是sql字符串,数据库怎么会知道strtodate(), t1.date, t2.date是什么意思呢?另外我把判断语句掉了个个,习惯把字段写在前面,要比较的数值写在后面。
      

  3.   

    Sql Server 同上差不多:
    select * from table1 where kaihu_Date between date1 and date2 union
    select * from table2 where kaihu_date between date1 and date2 union
    .....
    select * from table5 where kaihu_date between date1 and date2
      

  4.   

    t1.date是datetimepicker
    where前加空格也不对,我试过了,
    继续报错
    invalid use of keyword
    token:date
    怎么回事?
      

  5.   

    这是Oracle的写法select * from jiben_account 
      where strtodate(kaihui_date) between t1.date and t2.date
    union
    select * from yiban_account
      where strtodate(kaihui_date) between t1.date and t2.date
    union all
    select * from temp_account
      where strtodate(kaihui_date) between t1.date and t2.date
    union all
    select * from zuanyong_account
      where strtodate(kaihui_date) between t1.date and t2.date
    union  all
    select * from qita_account
      where strtodate(kaihui_date) between t1.date and t2.date
      

  6.   

    你有没有用参数呀?不会有问题呀。另外,你的表里有没有字段名为date的,改掉,这是数据库的保留字。
      

  7.   

    不对,我是过了,而且我也没有DATE字段
      

  8.   

    if (checkbox1.state=cbchecked)or (checkbox2.state=cbchecked) then改為:
    if (checkbox1.bchecked=True)or (checkbox2.bchecked=true) then
    試一下.
      

  9.   

    这里没问题,只是sql语句不对,到底怎么办????????????????????
      

  10.   

    最后一招,如果不行,我也没办法了
    add('select * from jiben_account,yiban_account,temp_account,zuanyong_account,qita_account');add(' where to_date(''yyyy-MM-dd'','+DateToStr(t1.date)+')<='+'to_date(''yyyy-MM-dd'','+kaihui_date+') and '+'to_date(''yyyy-MM-dd'','+DateToStr(t2.date)+')>='+'to_date(''yyyy-MM-dd'','+kaihui_date+')') ;
      

  11.   

    sql语句不应该出现Delphi的关键字,如strtodate(), t1.date, t2.date数据库不会认识的;to_date('format',string)是数据库的函数,将字符串转为日期。如果是Paradox数据库,format应该只能是MM/dd/yyyy。''两个引号是为了在一对单引号括起来的字符串中显示单引号。上面方法能行吗?希望能帮到你。
      

  12.   

    to chenpppp5678(chen) :
    **************************************************************
    注意:
        Sql 语句并不认识你写的t2.date 和t1.date是变量,他认为那是数据库中的字段,他将t2认为表名,将data认为是t2表的字段,所以报错!!
    你应该这样写:
       'where kaihui_date<='''+datetostr(t2.date)+''' and kaihui_date>='''+datetostr(t1.date)+'''') ;**************************************************************
    好啦,我不多说啦!!
    去试吧!!
      

  13.   

    又报错
    type  mismatch in expression
      

  14.   

    'where kaihui_date<='"'+datetostr(t2.date)+'"' and kaihui_date>='"'+datetostr(t1.date)+'"') ;
    这样才可以的!
      

  15.   

    将string改为日期的不就OK了,你不要以为string好写,当你要查询的时候就麻烦了!改成Datetime的类型的就OK了!
      

  16.   

    不好意思,Oracle中是to_date
    select * from jiben_account 
      where to_date(kaihui_date) between :t1 and :t2
    union
    select * from yiban_account
      where to_date(kaihui_date) between :t1 and :t2
    union
    select * from temp_account
      where to_date(kaihui_date) between :t1 and :t2
    union
    select * from zuanyong_account
      where to_date(kaihui_date) between :t1 and :t2
    union
    select * from qita_account
      where to_date(kaihui_date) between :t1 and :t2Query.ParamByName('t1').AsDate := T1.Date;
    Query.ParamByName('t2').AsDate := T2.Date;
    Query.Open;另外,你的kaihui_date是什么格式的,是否跟你数据库中的日期格式相同,不同的话要改,如To_Date(kaihui_date,'yy.mm.dd')
      

  17.   

    还是不行,难道一定要将kaihui_date的字段定为date型码,我原来是string
      

  18.   

    你原来kaihui_date的格式是什么?现在报什么错?