Get row where datetime column = today - SQL server noob

后端 未结 5 905
旧巷少年郎
旧巷少年郎 2020-12-03 04:32

In sql 2005, instead of building a query from dateparts year, month and date,

is there an more succinct way of writing the where clause?

5条回答
  •  死守一世寂寞
    2020-12-03 05:07

    Something along the lines of this

    CONVERT(date,tbldata.date)=CONVERT(date,getdate())
    

    This assumes that the date column includes the time as well. If it does not then you can change it to

    tbldata.date=CONVERT(date,getdate())
    

提交回复
热议问题