implicit conversion datetime error

  • Thread starter Thread starter JEM
  • Start date Start date
J

JEM

Help! I don't understand why I am getting the error message:

"Implicit conversion from datatype datetime to int is not allowed. Use
the CONVERT function to run this query."

I am using parameters to find records in a range of dates in a
function. Below is the simplified version of the SQL.

SELECT dbo.tblAuctions.EntityID, dbo.tblAuctions.AuctionDate,
dbo.tblAuctions.DueDate,
FROM dbo.tblEntities INNER JOIN dbo.tblAuctions ON
dbo.tblEntities.EntityID = dbo.tblAuctions.EntityID
WHERE (dbo.tblAuctions.EntityID = @entityid) AND
(dbo.tblAuctions.AuctionDate) BETWEEN @date1 AND @date2

When i enter in specific dates (Between 01/01/06 and 12/31/06) it runs
fine, but as soon as i change the dates into the parameters (Between
@date1 and @date2), i get the error message. I even tried using
CONVERT(DATETIME, @date1, 102)) to no avail.

Any ideas?

Thanks!!!
Jenn
 
Probably because @date1 and @date2 are not of type DateTime. When using the
Convert function, you must apply to @date2, too.

Another possibility is that AuctionDate is not of type DateTime, too. (For
example, it's a string.)
 
Thanks, actually i just figured it out. I think when the function was
first created, the parameters were in a different order. I recreated
it and made sure the parameters were defined in the correct order and
now it works!

Jenn
 
Back
Top