SQL Server : fetching records between two dates?

前端 未结 6 926
暖寄归人
暖寄归人 2020-12-13 21:23

In SQL I write a SELECT statement to fetch data between two dates, using between and

Ex:

select * 
from xxx 
where dates b         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 21:44

    You need to be more explicit and add the start and end times as well, down to the milliseconds:

    select * 
    from xxx 
    where dates between '2012-10-26 00:00:00.000' and '2012-10-27 23:59:59.997'
    

    The database can very well interpret '2012-10-27' as '2012-10-27 00:00:00.000'.

提交回复
热议问题