MS SQL Date Only Without Time

后端 未结 12 1560
有刺的猬
有刺的猬 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:22

    The Date functions posted by others are the most correct way to handle this.

    However, it's funny you mention the term "floor", because there's a little hack that will run somewhat faster:

    CAST(FLOOR(CAST(@dateParam AS float)) AS DateTime)
    

提交回复
热议问题