How can I group by date time column without taking time into consideration

I have a bunch of product orders and I’m trying to group by the date and sum the quantity for that date. How can I group by the month/day/year without taking the time part into consideration?

3/8/2010 7:42:00 should be grouped with 3/8/2010 4:15:00

  • show create table tablename (how do i do this in sql server)?
  • The multi-part identifier “System.Data.DataRowView” could not be bound." SQL SERVER + VB.NET
  • Query from SQL to MySQL
  • Dynamic input to sql query Using
  • How can I specify an index hint in Entity Framework?
  • Converting arithmetic formula in a string into a values
  • 5 Solutions collect form web for “How can I group by date time column without taking time into consideration”

    Cast/Convert the values to a Date type for your group by.

    GROUP BY DATEADD(day, DATEDIFF(day, 0, MyDateTimeColumn), 0)

    Or in SQL Server 2008 onwards you could simply cast to Date as @Oded suggested:

    GROUP BY CAST(orderDate AS DATE)

    In pre Sql 2008 By taking out the date part:

    GROUP BY CONVERT(CHAR(8),DateTimeColumn,10)

    Here’s an example that I used when I needed to count the number of records for a particular date without the time portion:

    select count(convert(CHAR(10), dtcreatedate, 103) ),convert(char(10), dtcreatedate, 103)
    FROM dbo.tbltobecounted
    GROUP BY CONVERT(CHAR(10),dtcreatedate,103)
    ORDER BY CONVERT(CHAR(10),dtcreatedate,103)

    Here is the example works fine in oracle

    select to_char(columnname, 'DD/MON/yyyy'), count(*) from table_name group by to_char(createddate, 'DD/MON/yyyy');
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.