• awcrestview (4/8/2014)


    Lynn,

    Thanks for you help Lynn, you're awesome. Below is from your recommendation with minor change to get what I needed.

    WHERE start_datetime >= dateadd(hour, -1, dateadd(day, datediff(day, 0, (getdate)), 0)) and DateDiff(day, End_DateTime, 'getdate')=0

    Just realize that this part of the where clause, DateDiff(day, End_DateTime, 'getdate') = 0, is not SARGable meaning you will not make use of any indexes. This part requires the every row needs to be tested to determine if the difference in days between End_DateTime and GETDATE() = 0.