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

后端 未结 8 1098
孤独总比滥情好
孤独总比滥情好 2020-11-30 17:47

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

相关标签:
8条回答
  • 2020-11-30 18:25

    CAST datetime field to date

    select  CAST(datetime_field as DATE), count(*) as count from table group by CAST(datetime_field as DATE);
    
    0 讨论(0)
  • 2020-11-30 18:26

    In pre Sql 2008 By taking out the date part:

    GROUP BY CONVERT(CHAR(8),DateTimeColumn,10)
    
    0 讨论(0)
提交回复
热议问题