日期字段为smalldatetime,如"2008-1-7"这种格式。如何自动根据今天的日期,查找出数据库同月同日的全部数据?

解决方案 »

  1.   

    select * from tb where smalldatetime = '2008-1-7'
      

  2.   

    select * from tb where convert(varchar(10),日期,120) = '2008-01-07'
      

  3.   

    where day(Getdate()) = day(@tm) and month(@tm) = month(getdate())
      

  4.   

    day(Getdate()) = day(日期) and month(日期) = month(getdate())
      

  5.   

    select * from tableA where DATEPART(MM,DDATE)=DATEPART(MM,Getdate()) and DATEPART(DD,DDATE)=
    DATEPART(DD,getdate())
      

  6.   

    select * from tb where month(col)=month(getdate()) and day(col)=day(getdate());