Table1里面有一个字段  Birthday(日期型), 当然是记录年月日的,我想
查出今天生日的人, 也就是只要月和日是一样的, 就查出来,实在不知道
怎么写,请教!

解决方案 »

  1.   

    select * from table1 
    where to_char(birthday,'yyyymmdd')=to_char(sysdate,'yyyymmdd')
      

  2.   

    如果你后台连接的是Oracle,就这样写:
     select * from table1 where to_char(Birthday,'MM-DD')='03-15';
      

  3.   


    多谢一楼的兄台, 可是提示出错:“表达式中 to_char函数不存在!”顺便说一句, 我使用的是DAODataSet1访问Access数据库,
    Birthday为"日期/时间"型。
      

  4.   

    select * from tabel1 where birthday = #2004-03-15#
      

  5.   

    select * from tabel
    where CAST(month(birthday) AS CHAR(2))
         +CAST(day(birthday) AS CHAR(2))
         =CAST(month(getdate()) AS CHAR(2))
         +CAST(day(getdate()) AS CHAR(2))
      

  6.   

    select * from table1 
    where FormatDateTime(birthday,'yyyymmdd')=FormatDateTime(sysdate,'yyyymmdd')
    function FormatDateTime(const Format: string; DateTime: TDateTime): string;
      

  7.   

    试一试
    select * from table1 where month(birthday)=month(getdate()) and day(birthday)=day(getdate())