在delphi中,我要把年、月通过组合成一个字符串后当sql的查询条件,譬如year=2010   month=12
我要把这两个变量连接成201012,当作查询条件,
select * from 表 where date= year&month   
请教各位,正确的格式是什么样的

解决方案 »

  1.   

    select * from 表 where date= inttostr(year)+inttostr(month)
      

  2.   

    SELECT * FROM tb WHERE [date]=RTRIM(CAST( year AS CHAR))+RTRIM(CAST( month AS CHAR))
      

  3.   

    select * from tb where convert(char(6),[date])=convert(char(4),year)+convert(char(2),month) 
      

  4.   

    add('select * from tablename where date='''+year+month+'''');还可以再弄个变量
    temp:=year+month;
    add('select * from tablename where date='''+temp+'''');不过日期型的不都是像2010-11-01这种吗?
      

  5.   

    s:='select * from t where year(date)=2012 and month(date)=12'