Select a date without time (SQL Server (+)

This question already has an answer here:

  • How to return only the Date from a SQL Server DateTime datatype 37 answers

  • On SQL Server 2008 and higher, you should convert to date:

    SELECT CONVERT(date, (DATEADD(year, -1, GETDATE())))
    

    On older versions, you can do the following:

    SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, DATEADD(year, -1, GETDATE())))
    
    链接地址: http://www.djcxy.com/p/94382.html

    上一篇: 如何在SQL 2005中将日期时间转换为日期

    下一篇: 选择一个没有时间的日期(SQL Server(+)