Help Me Improve my DateTime Query
I have been using SQL Server 2000 for about two weeks now, and I just made my first complex query. I want to know a) things I am doing wrong b) things that can be done better, and c) how you would approach this problem. I read the other thread, but I am not
at all familiar with functions or procedures.
I am creating a query to return data based on the season associated with that row. Each row has a datetime associated with it.
I came up with the following query to return all the entries for Fall:
Select RelevantInfo from Site3 where
( (convert(char(2), start_time, 110) > 9) AND
(convert(char(2), start_time, 110) < 12) ) OR // month between sept and dec
( (convert(char(2), start_time, 110) = 9) AND
(convert(char(2), start_time, 105) > 22) ) OR // or in sept after 22nd
( (convert(char(2), start_time, 110) = 12) AND
(convert(char(2), start_time, 105) < 21) ) // or in dec before 21st
|