I have an sql statement comparing dates in the Where clause.
This is my code:
[CODE]
CONVERT(NVARCHAR, D.Spd_deldateans, 101) between @DATE1 AND @DATE2
[/CODE]
The problem with the statement, is that, it doesn't show any records when one of the parameters is blank or null. How would it be able to show records giving value only to either of the parameters?
PHANI NADIGADDAPosted Nov 17, 2006, 10:16 AM
You can accomplish this by giving some default value when the value is NULL
e.g
BETWEEN ISNULL(@DATE1, yourdefaultdate) AND ISNULL(@DATE2, yourdefaultdate)
It compares the yourdefaultdate when the values are null.
I guess it helps you.