How to compare only date part when delivery date is today

后端 未结 5 596
既然无缘
既然无缘 2021-02-05 08:59

I\'m trying to create a report that gets records from a SQL Server database where the delivery date is today.

I\'ve tried

select * from (tablename)
where         


        
5条回答
  •  日久生厌
    2021-02-05 09:11

    If delivery_date is always midnight (00:00:00.000), then compare it like this:

    select * from (tablename)
    where delivery_date = datediff(d, 0, getdate())
    

    Using datediff like this is a quick way to truncate the time part of a datetime value.

提交回复
热议问题