title: SQL: Comparing Dates with only Month and Year columns
body: <p>I have a table <code>MonthlyShipments</code> that looks like:</p>
  
  <pre><code>partnumber | quantity | month | year |
  part1      |       12 |     6 | 2011 |
  part1      |       22 |     5 | 2011 |
  part1      |       32 |     4 | 2011 |
  part1      |       42 |     3 | 2011 |
  part1      |       52 |     2 | 2011 |
  </code></pre>
  
  <p>I want to sum the quantities of the past 3 months, excluding the current month.  My where clause currently looks like:</p>
  
  <pre><code>where
    MonthlyShipments.Month &lt;&gt; MONTH(GETDATE()) AND 
    CAST(
      (CAST(MonthlyShipments.Month as nvarchar(2)) + 
      '-01-' + 
      CAST(MonthlyShipments.Year as nvarchar(4))) as DateTime)
    &gt; DATEADD(m, -4, GETDATE())
  </code></pre>
  
  <p>It works, but its ugly and insulting.  Any advice on making it prettier?  Much appreciate!</p>