Connecting Tech Pros Worldwide Help | Site Map

Problem with CONVERT function

  #1  
Old February 27th, 2007, 05:35 PM
Wes Peters
Guest
 
Posts: n/a
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 spESEnrollmentCount

@StartDate smalldatetime, @StopDate smalldatetime

As

SELECT tblCustomers.CustomerName, tblCostCenters.CostCenter,

COUNT(tblESEnrollments.EnrollmentID)

AS [Count of Enrollments]

FROM tblESEnrollments

INNER JOIN tblCustomers ON tblESEnrollments.CustID = tblCustomers.CustID

INNER JOIN tblCostCenters ON tblCustomers.CostCenterID =
tblCostCenters.CostCenterID

WHERE ( CONVERT(DATETIME, tblESEnrollments.DTStamp, 101) >= @StartDate) AND

( CONVERT(DATETIME, tblESEnrollments.DTStamp, 101) <= @StopDate) AND
(Rejected = 0)

GROUP BY tblCustomers.CustomerName, 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


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with CONVERT function Wes Peters answers 1 February 28th, 2007 04:25 PM
problem with Convert.FromBase64String function scottrm answers 5 December 23rd, 2005 12:35 PM
Problem with webservice returning an array (You must implement a default accessor on System.Array because it inherits from ICollection. )?? Stacey Levine answers 5 November 23rd, 2005 06:36 AM
How do I make my convert() function do nothing for equal types? Eric Lilja answers 4 July 23rd, 2005 02:27 AM