title: how to find end of quarter given a date in the quarter
body: <p>If i'm given a date (say @d = '11-25-2010'), how can I determine the end of the quarter from that date. I'd like to use a timestamp one second before midnight.</p>
  
  <p>I can get this:</p>
  
  <pre><code>select dateadd(qq, datediff(qq, 0, getdate()), 0) as quarterStart
  </code></pre>
  
  <p>which gives me: '10-1-2010'</p>
  
  <p>and I use this for one second before midnight of a given day:</p>
  
  <pre><code>select DateAdd(second, -1, DateAdd(day, DateDiff(day, 0, @d))+1, 0) ) AS DayEnd
  </code></pre>
  
  <p>in the end, a quarterEnd method would give me '12-31-2010 23:59:00'</p>