Geeks With Blogs


Agha Usman Ahmed JILAWATAN

There are times when we need to group by the table with the date. But Datetime field also contain time part which is very deep. So, there is no way you can group by datetime field and see correct records because it will group by including the time portion of DateTime field.

So, to get rid off the time portion in group by clause here is a quick query.

   1: select  dateadd(dd,0, datediff(dd,0,dateCreated)) as Date,count(*) TotalCount  from tblRecords   
   2: group by dateadd(dd,0, datediff(dd,0,dateCreated)) 
Posted on Friday, February 27, 2009 4:41 PM SQL Server | Back to top

Comments on this post: How to Group by Just Date Portion Of DateTime Field

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Agha Usman Ahmed | Powered by: