• Mark Eytcheson (6/29/2009)


    I usually create two datasets:

    1. StartDate

    SELECT CAST((CONVERT(varchar(10), GETDATE()-9, 101)) AS DATETIME) AS StartDate

    2. EndDate

    SELECT CAST((CONVERT(varchar(10), GETDATE()-2, 101) + ' 23:59:59') AS DATETIME) AS EndDate

    Then set the parameters @StartDate and @EndDate equal to the values of these two datasets.

    SELECT CAST((CONVERT(varchar(10), GETDATE()-2, 101) + ' 23:59:59') AS DATETIME) AS EndDate --> This will miss any records with a datetime value > [Date] 23:59:59.000 and [Date + 1] 00:00:00.000.