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.
| Author |
Topic |
|
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2009-04-02 : 06:09:14
|
| Hi GuysI have a table that contains customer registration details. A trimmed down version is shown as follows:Customer RegID, DateRegistered1,2009-01-112,2009-01-123,2009-01-194,2009,01-21Etc...The thing I am trying to do is produce a report with a count of customers grouped by week. The date shown will have to have to be the week starting date and have to be on a Monday.So it will look similar to:Week Starting , Count 5/01/2009, 1112/01/2009, 2219/01/2009, 3226/01/2009, 23I hope this all makes sense!Thanks |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2009-04-02 : 06:15:03
|
| You can get the start & end date of current week like this with the start day as mondayselect MIN(DATEADD(wk, DATEDIFF(wk,7, GETDATE()), 7))as startdate , MIN(DATEADD(dd,7,DATEADD(wk, DATEDIFF(wk, 6, GETDATE()), 6))) as enddate |
 |
|
|
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2009-04-02 : 07:47:22
|
| HeyThanks I'll give it a try |
 |
|
|
|
|
|
|
|