title: need date in the format yyyy-mm in mssql
body: <p>need the date in the format yyyy-mm and should be grouped to get 
  the count but when i give the </p>
  
  <pre><code>group by date is says invalid
  </code></pre>
  
  <p>i have found this solution </p>
  
  <p>can anyone help me by providing other solution</p>
  
  <pre><code>select 
  count(*) as count, 
  Convert(char(10), RH.updated_datetime, 105) as date,
  SUM( 
    datediff(SECOND, 
         PRI.procedure_performed_datetime ,RH.updated_datetime
    )
  )/count(*) as average_reporting_tat 
  from 
  report R, 
  report_history RH, 
  study S, 
  procedure_runtime_information PRI, 
  priorities PP, 
  patient P, 
  "procedure" PR 
  
  where 
  
  RH.report_fk=R.pk and RH.pk IN ( 
    select pk from ( 
      select * from report_history where report_fk=r.pk  
    ) as result 
    where old_status_fk IN (21, 27)
  ) AND R.study_fk = S.pk 
  AND S.procedure_runtime_fk = PRI.pk 
  AND PRI.procedure_fk = PR.pk 
  AND S.priority_fk = PP.pk 
  AND PRI.patient_fk = P.pk 
  AND RH.updated_datetime &gt;= '2012-05-01' 
  AND RH.updated_datetime &lt;= '2013-09-12' 
  group by Convert(char(10), RH.updated_datetime, 105)
  </code></pre>