Evaluating IF something is in a list
I have a function that checks if the input @InDate is a weekend by using IF DATEPART(dw, @InDate) is equal to 1 or 7, then returning true or false.
I can get it to work using two separate comparisons, IF DATEPART(...) = 1 OR DATEPART(...) = 7, but I also know a normal SELECT can use something like
SELECT column FROM table WHERE column IN (1,7)
That's a nice easily readable way of checking for a variety of values (as opposed to the alternative WHERE column = 1 OR column = 7 OR column = ...).
Can I make IF condition "set based" like that?
|