Problem with CONVERT function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wes Peters

    Problem with CONVERT function

    I have a situation where I want to filter records for a given day. The
    field that stores the date/time uses the date() function as a default value,
    kind of a date/time stamp for the record.

    The problem is when I want to filter records for a given day instead of a
    date range. I use the CONVERT function to return just the date part of the
    field (101 as a style parameter) and compare that to a start and stop date
    (both being the same) and I get nothing. The stored procedure is as
    follows:

    Alter Procedure spESEnrollmentC ount

    @StartDate smalldatetime, @StopDate smalldatetime

    As

    SELECT tblCustomers.Cu stomerName, tblCostCenters. CostCenter,

    COUNT(tblESEnro llments.Enrollm entID)

    AS [Count of Enrollments]

    FROM tblESEnrollment s

    INNER JOIN tblCustomers ON tblESEnrollment s.CustID = tblCustomers.Cu stID

    INNER JOIN tblCostCenters ON tblCustomers.Co stCenterID =
    tblCostCenters. CostCenterID

    WHERE ( CONVERT(DATETIM E, tblESEnrollment s.DTStamp, 101) >= @StartDate) AND

    ( CONVERT(DATETIM E, tblESEnrollment s.DTStamp, 101) <= @StopDate) AND
    (Rejected = 0)

    GROUP BY tblCustomers.Cu stomerName, tblCostCenters. CostCenter



    If I put 10/31/06 in for both parameters shouldn't I get records dated
    10/31/06 if there are some?

    Thanks,

    Wes


Working...