MS SQL Date Only Without Time

后端 未结 12 1535
有刺的猬
有刺的猬 2020-12-13 02:02

Question

Hello All,

I\'ve had some confusion for quite some time with essentially flooring a DateTime SQL type using T-SQL. Essentially, I want to take a

12条回答
  •  有刺的猬
    2020-12-13 02:33

    DATEADD(d, 0, DATEDIFF(d, 0, [tstamp]))
    

    Edit: While this will remove the time portion of your datetime, it will also make the condition non SARGable. If that's important for this query, an indexed view or a between clause is more appropriate.

提交回复
热议问题