我的一个表有日期/时间型字段birthday,现在要用SQL查出年龄在20-30岁之间的记录,这样的SQL怎么写?

解决方案 »

  1.   

    select * from table1 where  datediff(d,birthday,getdate())>=20 and datediff(yy,birthday,getdate())<=30
      

  2.   

    select * from table1 where  datediff(yy,birthday,getdate())>=20 and datediff(yy,birthday,getdate())<=30
      

  3.   

    我照格式写了,运行的时候提示我“getdate"函数没有定义,我已经加了DateUtils了,请赐教!
      

  4.   

    adoquery.sql.add('select * from table1 where  datediff(yy,birthday,getdate())>=20 and datediff(yy,birthday,getdate())<=30')
      

  5.   

    select * from Talbe where  datadiff(yy,birthday,getdate()) between 20 and 30
      

  6.   

    运行的时候提示我“getdate"函数没有定义
      

  7.   

    select * from table where datadiff(yy,birthday,getdate()) between 20 and 30
      

  8.   

    adoquery.sql.add('select * from table1 where  datediff(yy,birthday,getdate())>=20 and datediff(yy,birthday,getdate())<=30')
      

  9.   

    getdate()是SQL SERVER中的函数你的数据库是?
      

  10.   

    select * from table1 where  datediff('y',birthday,now())>=20 and datediff('y',birthday,now())<=30
      

  11.   

    写成这样,运行的时候提示“参数Y没有默认值”
    datediff(y,birthday,now())写成这样,编译的时候提示丢失操作符
    datediff('y',birthday,now())新手很麻烦,大家多多帮忙!
      

  12.   

    datediff(yy,birthday,getdate())中YY是什么参数?
      

  13.   

    ADOQuery1.Close;
    ADOQuery1.SQL.Text := 'Select * From Employee Where DateDiff("y",Birthday,now()) between 20 and 40';
    ADOQuery1.Open;我这样写,编译可以通过,也可以执行,但没有记录出来,我确定表里有符合条件的记录,麻烦大家帮忙看看。
      

  14.   

    ADOQuery1.Close;
    ADOQuery1.SQL.Text := 'Select * From Employee Where DateDiff("y",Birthday,now()) between 20 and 40';
    ADOQuery1.Open;我这样写,编译可以通过,也可以执行,但没有记录出来,我确定表里有符合条件的记录,麻烦大家帮忙看看。谁知道是怎么回事?