Home Forums SQL Server 2008 T-SQL (SS2K8) Using >= or <= with DateTime parameter not working? RE: Using >= or <= with DateTime parameter not working?

  • phoeneous 65427 (10/21/2014)


    This works when I apply it to the query, no need to filter in ssrs.

    AND (OrderDate BETWEEN (@StartDate ) AND (@EndDate + '23:59:59'))

    I have never been a big fan of doing queries with a time component when it is not used or not needed.

    If your data types are all datetime, then the following query will get all the rows in the range. If it does not, then something else is wrong.

    AND OrderDate >= @StartDate and OrderDate < DATEADD(dd, 1, @EndDate)

    __________________________________________________________________________________________________________
    How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/