Best way to compare dates without time in SQL Server

前端 未结 7 1218
半阙折子戏
半阙折子戏 2020-12-15 17:17
select * from sampleTable 
where CONVERT(VARCHAR(20),DateCreated,101) 
=     CONVERT(VARCHAR(20),CAST(\'Feb 15 2012  7:00:00:000PM\' AS DATETIME),101)
7条回答
  •  星月不相逢
    2020-12-15 17:57

    declare @DateToday Date= '2019-10-1'; print @DateToday;

    print Abs(datediff(day, @DateToday,CAST('oct 1 2019 7:00:00:000PM' AS DATETIME))) < 3

    this is compare whin 3 days.

    i test this on SQL Server 2014, it works.

提交回复
热议问题