Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 group date

Author  Topic 

mike13
Posting Yak Master

219 Posts

Posted - 2012-02-09 : 11:14:09
Hi all,

i got this select
Select count(orderid) as amounts, shipdate from T_Order_Lost_Log group by shipdate

problem is the shipdate field, has time in it also.
How can ai group just on the year,month,day ?

thanks a lot

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-02-09 : 11:21:14
Select
count(orderid) as amounts,
dateadd(d,datediff(d,0,shipdate),0) as shipdate
from T_Order_Lost_Log
group by dateadd(d,datediff(d,0,shipdate),0)


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

mike13
Posting Yak Master

219 Posts

Posted - 2012-02-09 : 11:42:24
Thanks a lot :-)
Go to Top of Page
   

- Advertisement -