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 2000 Forums
 Transact-SQL (2000)
 Group By Week

Author  Topic 

josethegeek
Starting Member

45 Posts

Posted - 2004-08-02 : 20:36:56
Hello,
Could someone help me with grouping data by Weeks. We currently have a table that keeps track of every visitor to our site. It logs the date and assigns the visitor an ID. I want to be able to pass in a start date and an end date and return the records ordered by Week.

This is the table..

tbl_Visitors
Visitor_ID int
Visitor_StartDate datetime

I wrote an asp script that get the ending Saturday of every week of the day, that is what needs to get passed.

Hopefully I didn't confuse anyone.

Thanks In Advance,
Jose

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-08-02 : 20:49:45
To do it simply, you can use the DatePart(ww, <date>) to get the number of the week in the year.

Just to clarify - are you trying to return a week end date for every occurence of Visitor_StartDate?

If you're looking for the week end date, check out the following:
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=37499[/url]
Go to Top of Page

josethegeek
Starting Member

45 Posts

Posted - 2004-08-03 : 13:04:08
quote:
Originally posted by timmy

To do it simply, you can use the DatePart(ww, <date>) to get the number of the week in the year.

Just to clarify - are you trying to return a week end date for every occurence of Visitor_StartDate?

If you're looking for the week end date, check out the following:
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=37499[/url]



Timmy,
Actually to make it easier lets make the Visitor_StartDate, just Visitor_Date

Through ASP I am able to generate a list of every saturday of the year. I want to pass in the starting saturday and ending saturday. And if they are 2 months apart. I want to display all 8 saturdays with the total visitor results.

Thanks,
Jose
Go to Top of Page

josethegeek
Starting Member

45 Posts

Posted - 2004-08-03 : 16:44:43
Thanks timmy, I looked around the site and found the answer at

http://www.sqlteam.com/item.asp?ItemID=851

Thanks Again,
Jose
Go to Top of Page
   

- Advertisement -