How to group by date time in MS SQL Server

by mikael 15. May 2009 12:24

select   count(*),
   cast(convert(varchar,a.CreatedDate,101) as smalldatetime) as VisitDate
from     ActivityLogs.dbo.DetectionLogs a
where   a.Column = 'value'
group by cast(convert(varchar,a.CreatedDate,101) as smalldatetime)
order by cast(convert(varchar,a.CreatedDate,101) as smalldatetime) asc

This is extremely useful to gather some quick statistics! :)

Tags:

SQL Server

blog comments powered by Disqus

About the author

Life architect specialized in programming