sqlserver2000下有个表(t_oa_sys_account)
其中有个字段(birthday)类型(datetime)里面存放着yyyy-mm-dd格式日期我只想获得当前系统日期,然后在表里查询是否有和当前日期相匹配的
如果有就将此条记录name字段的姓名提出来存放到一个变量里,基本过程
就这样,希望哪个高手将这段代码写出来让小弟学习一下。小弟将另开帖子给这位兄弟100分。

解决方案 »

  1.   

    select name from t_oa_sys_account where birthday = getdate()
      

  2.   

    select *
    from Table
    where MONTH (getdate())=MONTH (birthday)
         And Day(getdate())=Day(birthday)
      

  3.   

    简单,一个语句就搞定了select name from t_oa_sys_account where birthday=left(convert(varchar(100),getdate(),20),10)
      

  4.   

    哦,刚才写错了一点select name from t_oa_sys_account where substring(birthday,6,5)=left(convert(varchar(100),getdate(),110),5)