I’ve tried to compare a date passed as parameter to a stored procedure from asp.net with a date in database. But cannot yield the needed result..
My query is as follows:
@date datetime
Select * from table
where (CONVERT(NVARCHAR,[date],112)=CONVERT(NVARCHAR,@date,112))
I’ve no issue to insert a date passed as a parameter from asp.net, the sql server takes care of the date format..
Any one please tell me how i can compare those dates..
The correct way to do this is
edit: if you just want to compare the date component (excluding time) in SQL2005, compare the year, month and day.
I always prefer avoiding string comparisons.