Does BETWEEN with dates actually work in SQL SERVER 2008

后端 未结 8 963
旧时难觅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

    In Oracle:

    select
        case when '1/1/08' between '1/1/08' and '2/1/08'
            then 'in' else 'out' end as s1,
        case when '1/1/08' between '12/31/07' and '1/1/08'
            then 'in' else 'out' end as s2
    FROM dual
    
    in out
    

    You are comparing strings here, not dates.

    There is nothing BETWEEN 12/31/07 and 1/1/08, as 2 goes after / in ASCII

提交回复
热议问题