MS SQL Date Only Without Time

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

    FWIW, I've been doing the same thing as you for years

    CAST(CONVERT(VARCHAR, [tstamp], 102) AS DATETIME) = @dateParam 
    

    Seems to me like this is one of the better ways to strip off time in terms of flexibility, speed and readabily. (sorry). Some UDF functions as suggested can be useful, but UDFs can be slow with larger result sets.

提交回复
热议问题