Group by date from a DateTime field in SQL Server

SELECT CAST(DateTimeField AS DATE) AS VisitDate, COUNT(RetailerId) AS RetailerQuantity
FROM TableName 
WHERE CAST(DateTimeField AS DATE) =’2014-08-08′ 
GROUP BY CAST(DateTimeField AS DATE) 
ORDER BY CAST(DateTimeField AS DATE) desc
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s