Best approach to remove time part of datetime in SQL Server

前端 未结 23 1668
南旧
南旧 2020-11-21 22:51

Which method provides the best performance when removing the time portion from a datetime field in SQL Server?

a) select DATEADD(dd, DATEDIFF(dd, 0, getdate(         


        
23条回答
  •  忘了有多久
    2020-11-21 23:13

    CAST(round(cast(getdate()as real),0,1) AS datetime)
    

    This method does not use string function. Date is basically a real datatype with digits before decimal are fraction of a day.

    this I guess will be faster than a lot.

提交回复
热议问题