title: Month to Date in SQL Server 2008
body: <p>Hopefully this will be an easy one to answer. </p>
  
  <p>I am working on a table that requires MTD data. One of our SQL guys told me to use </p>
  
  <pre><code>MONTH (@monthtodate)= 11
  </code></pre>
  
  <p>Where <code>@monthtodate</code> is set to <code>GetDate()</code> in the parameter list in SQL Server Management Studio. So in "theory", he says, it should select the month (11) and then get today and return all the requested data in between those two dates. But I'm thinking this isn't correct. </p>
  
  <p>In looking at my data I'm starting to think that It's just returning data for the whole month of November instead of just MTD. I guess, technically, anything that has 0 won't be calculated. However that just means it's poorly written code correct?</p>
  
  <p>In your opinions, would this be the better way to return MTD data:</p>
  
  <pre><code>production_date &lt;= @today and Production_Date &gt;= DATEADD(mm, DATEDIFF(mm, 0, @today), 0)
  </code></pre>
  
  <p>Thanks in advance everyone!</p>