Get row where datetime column = today - SQL server noob

后端 未结 5 921
旧巷少年郎
旧巷少年郎 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 04:52

    Not good performance, but a solution:

    SELECT * 
    FROM tblDate
    WHERE CONVERT(VARCHAR, date, 112) = CONVERT(VARCHAR, GETDATE(), 112);
    

    If it is a common query a computed column should be added with only year-month-day content.

提交回复
热议问题