Best approach to remove time part of datetime in SQL Server

前端 未结 23 1686
南旧
南旧 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:29

    In SQL Server 2008, there is a DATE datetype (also a TIME datatype).

    CAST(GetDate() as DATE)
    

    or

    declare @Dt as DATE = GetDate()
    

提交回复
热议问题