• Hi Chris,

    My *recommendation* wasn't a comparison between my code vs. Jack's code. It was a recommendation on my own code.

    The reason I added this is that Jack's method does not work for some of my existing systems as some data is loaded from text files with date values used for data retrieval but the source systems MySQL, Interbase, DB2, etc does not include the time value as the "DATE" datatype is used, thus date is "xxxx/xx/xx 00:00:00" in MS SQL. When Jacks method is used data for an additional day is retrieved. Which is incorrect. Jack's code whould have to be modified to SELECT COUNT(*)

    FROM #DateTest

    WHERE TestDate >= @Startdate and TestDate < DATEADD(ss, -1, @Enddate+1) which doesn't work but this does SELECT COUNT(*)

    FROM #DateTest

    WHERE TestDate BETWEEN @Startdate and DATEADD(ss, 86399, @Enddate)

    We have standardised on using DATEADD(dd, DATEDIFF(dd, 0, [DateTime]), 0) because this cateres for DATEADD(dd, DATEDIFF(dd, 0, [DateTime]), 0) = @InputDate