How can I pull data from a SQL Database that spans an academic year?

Posted by Eric Reynolds on Stack Overflow See other posts from Stack Overflow or by Eric Reynolds
Published on 2010-06-14T19:12:43Z Indexed on 2010/06/14 19:22 UTC
Read the original article Hit count: 239

Filed under:
|

Basically, I want to pull data from August to May for a given set of dates. Using the between operator works as long as I do not cross the year marker (i.e. BETWEEN 8 AND 12 works -- BETWEEN 8 AND 5 does not). Is there any way to pull this data? Here is the SQL Query I wrote:

SELECT count(*), MONTH(DateTime)
FROM Downloads
WHERE YEAR(DateTime) BETWEEN 2009 AND 2010 AND MONTH(DateTime) BETWEEN 8 AND 5 
GROUP BY MONTH(DateTime)
ORDER BY MONTH(DateTime)"

Any help is appreciated.

Thanks,

Eric R.

© Stack Overflow or respective owner

Related posts about sql

Related posts about datetime