crystalhelp
Programmer
The following statement works in some spots and not in others: convert(datetime,b.dateval) >= DateADD(year,-@Years,GetDate()) and convert(datetime,b.dateval) <= getdate()
b.dateval is a char and @years is an int.
It works when I have it in a basic where clause, but it doesn't work if I have it in a where clause that is 3 where clauses deep. That is the only difference I can figure out. The error I'm getting is Server: msg 242 - The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Do you know why?
b.dateval is a char and @years is an int.
It works when I have it in a basic where clause, but it doesn't work if I have it in a where clause that is 3 where clauses deep. That is the only difference I can figure out. The error I'm getting is Server: msg 242 - The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Do you know why?