Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group by date/Ignore time

Status
Not open for further replies.

rrajarat

MIS
Oct 8, 2002
42
US
How can I group by date in a query for SQL 2000 and ignore the time. I want to get the total quantity for a day. Problem is that datetime and smalldatetime Which prevents me from doing this. In Sybase I caould convert the data type to a date and that woiuld drop the time. Is there a way to do this in sql 2000?
 
You can convert to DATE in SQL Server also.

Select
Convert(char(10), DateCol, 120) As DateCol,
Sum(qty) As TotQty
From TableName
Group By Convert(char(10), DateCol, 120) If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top