• ScottPletcher (8/19/2014)


    My preference would be this (the "extra" parentheses are important to properly match the requirements):

    SELECT *

    FROM YourTable

    WHERE (SnapshotDate > @from AND SnapshotDate < @to)

    OR (SnapshotDate = @from AND HourKey >= 3)

    OR (SnapshotDate = @to AND HourKey <= 20)

    My preference would be to have a decent datetime column 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP