Compare DATETIME and DATE ignoring time portion

前端 未结 5 2563
清酒与你
清酒与你 2020-11-27 03:13

I have two tables where column [date] is type of DATETIME2(0).

I have to compare two records only by theirs Date parts (day+month+year), di

5条回答
  •  失恋的感觉
    2020-11-27 03:24

    You can try this one

    CONVERT(DATE, GETDATE()) = CONVERT(DATE,'2017-11-16 21:57:20.000')
    

    I test that for MS SQL 2014 by following code

    select case when CONVERT(DATE, GETDATE()) = CONVERT(DATE,'2017-11-16 21:57:20.000') then 'ok'
                else '' end
    

提交回复
热议问题