我的会员表里只有出生年月这一列,是datetime 的,我现在想查询出所有年龄在 15到49周岁里的会员资料,请问应该怎么做啊?
谢谢!

解决方案 »

  1.   

    获取当前时间  然后用 datediff 来写  但是,如果是sybase的话 我们公司升级到12.5后 用datediff 函数 性能会影响很大 不知道什么原因  以前在11.9的适合都好好的
      

  2.   

    select *
    from yourtable
    where  birthday < dateAdd(yy, -15, getdate()) and birthday > dateAdd(yy, -49, getdate()) 
      

  3.   

    select xxxxx(要查的字段名) from TableName(表名) 
    where datediff(year,'xxxxx(你自己的这个字段)','"+DateTime.Now+"') 
    between 15 and 50