DATETIME Puzzle

  • GilaMonster (11/17/2011)


    Ola L Martins-329921 (11/17/2011)


    The "AND" operator will check against the date-columns seperately - not simultaneously which in the case with "BETWEEN".

    Using GREATER THAN and LESS THAN in the above question would actually return all the records.

    BETWEEN is completely equivalent to a combination of <= and >=

    SomeColumn BETWEEN @Var1 and @Var2 is exactly the same as SomeColumn >= @Var1 and SomeColumn <= @Var2. In fact, the SQL parser converts the BETWEEN into the <= and >= form during parsing (pre-execution)

    Interesting side-fact: BETWEEN is not valid in a filtered index definition; you have to expand the condition into >= and <= tests.

  • Thanks to all who posted comments. I myself got to learn more by reading all the comments.

  • good question with good expatiation

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!

Viewing 3 posts - 31 through 33 (of 33 total)

You must be logged in to reply to this topic. Login to reply