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 2005 Forums
 Transact-SQL (2005)
 Gruop By (weekdays)?

Author  Topic 

Babaksql
Starting Member

32 Posts

Posted - 2008-11-12 : 02:11:40
Hi
Could you please tell me how we can use the GROUP BY to group records based on a specific weekday such as Monday or Tuesday,.... Suppose that the field which represents the date is DateField.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-12 : 02:22:44
GROUP BY DATEPART(dw,DateField)
Go to Top of Page

Babaksql
Starting Member

32 Posts

Posted - 2008-11-12 : 03:02:46
I mean how we can group records weekly based on a pre-defined day of week. I know that by having GROUP BY DATEPART (ww, DateField), we can group records weekly. My question is how we can do it for a specific day, for example from each Tuesday to the next Tuesday. Thanks
Go to Top of Page

malaytech2008
Yak Posting Veteran

95 Posts

Posted - 2008-11-12 : 03:18:38
use datepart in BETWEEN and AND and group by datefield.

malay
Go to Top of Page
   

- Advertisement -