>What happen if I would like to search for date range query?
>Eg. given 2 dates for any records that are between these
>2 dates. Could you show me some examples on how to achieve
>the results. Excuse me for being a newbie in SQL. Thanks.
>
I've had lots of luck using DATEPART() and breaking the date into to components: day of year and year. The SQL looks ugly but works:
WHERE (DATEPART(dy, t.datefield) >= DATEPART(dy, @LowerBound) AND DATEPART(yy, t.datefield) >= DATEPART(yy, @LowerBound)) AND (DATEPART(dy, t.datefield) <= DATEPART(dy, @UpperBound) AND DATEPART(yy, t.datefield) <= DATEPART(yy, @UpperBound))
Does anyone else have a solution?
-Mike