• Alex Fekken (5/17/2013)


    If someone asks me to pick a number between 1 and 3 I don't think I'm forced to choose '2'.

    Nice attempt at a "proof by intimidation" but I would see it as an invitation to pick a non-integer! 🙂

    If you change the numbers to 1 and 30 (and explicitly ask for an integer) then I doubt that 1 and 30 would be as likely outcomes as the other integers in the range.

    I have frequently heard high school exam grades being refered to as numbers between 1 and 10. I have never heard anyone call them a number between 0 and 11.

    But then, I am not a native English speaker, so what do I know?

    However, with other data types than integer values, there is indeed amibiguity in the English use of "between". On a numeric (non-integer) scale, when a value is between 11 and 35, I expect the values 11.000 and 35.000 to be included, just as (obviously) 11.001 and 34.999, but not 35.001. Just as the SQL operator BETWEEN is defined for numeric data types.

    However, with points in time, when people say between now and May 25, I expect May 25, 4:28 PM to be still included. For SQL with datetime and similar data types, the cutoff point would be May 25, midnight - one second later would be outside the range.

    (edit: I would not even calls this a 'bug', like I would call certain other "features", but simply a 'bad choice')

    Agreeed. This is definitely not a bug. I would call this a non-intuitive implementation choice. (And note that this choice is not made by the Microsoft team; they only followed what has been defined in the ISO/ANSI standard for SQL).


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/