0

Hi all,

Batchdate comes in as string format (07/07/2011). I tried but for some reason am not getting any results.

Any ideas?

ALTER PROCEDURE  dbo.CouponReportbyScheme
	
	(
	
	@BatchDate varchar(20) 
	
	)
	
AS	

	 
	declare @myDate  datetime
	select  @myDate =  convert( datetime, @BatchDate) 
         Select * from Coupons where CouponGenerationDate=@myDate
4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by BitBlt
0

Also depends on what the datatype of column CouponGenerationDate is in the table. If it is not a datetime, you might have problems. If it IS a datetime, and if it contains a "time" portion, that might mess up your comparison, too.

Also, your CONVERT statement needs to have a format, as in

CONVERT(datetime, @BatchDate, 101)

To be safe, if you can't change the datatype on your table, use CONVERT on both parts of the comparison, like so:

Select * from Coupons 
where CONVERT(datetime, CouponGenerationDate, 101) = CONVERT(datetime, @BatchDate, 101)

Hope this helps!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.