Does BETWEEN with dates actually work in SQL SERVER 2008

后端 未结 8 910
旧时难觅i
旧时难觅i 2021-01-20 00:36

According to cdonner, in his answer here and on his blog.

He claims that BETWEEN with date yields inconsistent results

From his blog:

<
8条回答
  •  一向
    一向 (楼主)
    2021-01-20 01:00

    Just never ever use BETWEEN with datetime values. In MySQL I can do

    created >= CURDATE() - INTERVAL 1 DAY AND created < CURDATE()
    

    to limit created to (the whole of) yesterday.

    With BETWEEN '2011-05-02' AND '2011-05-02 23:59:59' I would be gambling on one-second resolution, and would miss a created of '2011-05-02 23:59:59.001'.

提交回复
热议问题