View Single Post
 
Old 04-09-2015, 01:25 PM
holtzy holtzy is offline
Senior Contributor
 
Join Date: Jul 2002
Location: USA
Posts: 1,054
Talking T-SQL DateTime Parameter

There are posts all over the web about DateTime Parameters in stored procedures, but I still cannot figure this out. I have a parameter that gets passed in successfully as a datetime (@parAuditDate datetime), but when I use it in a query:
Code:
...WHERE        (fldAuditDate = @parAuditDate)
it always returns zero rows. However, if I convert it to a varchar before I use it in the query, it returns a row:
Code:
declare @varAuditDate varchar(25)
	set @varAuditDate = convert(varchar(25), @parAuditDate, 120) 
...WHERE        (fldAuditDate = '' + @varAuditDate + '')
Am I missing something simple?
__________________
God is good!!!
Reply With Quote