Best approach to remove time part of datetime in SQL Server

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

    I really like:

    [date] = CONVERT(VARCHAR(10), GETDATE(), 120)
    

    The 120 format code will coerce the date into the ISO 8601 standard:

    'YYYY-MM-DD' or '2017-01-09'
    

    Super easy to use in dplyr (R) and pandas (Python)!

提交回复
热议问题