How to select date without time in SQL

后端 未结 17 2093
灰色年华
灰色年华 2020-11-28 20:09

When I select date in SQL it is returned as 2011-02-25 21:17:33.933. But I need only the Date part, that is 2011-02-25. How can I do this?

17条回答
  •  粉色の甜心
    2020-11-28 21:04

    If you want to return a date type as just a date use

    CONVERT(date, SYSDATETIME())
    

    or

    SELECT CONVERT(date,SYSDATETIME()) 
    

    or

    DECLARE @DateOnly Datetime
    SET @DateOnly=CONVERT(date,SYSDATETIME())
    

提交回复
热议问题