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)
 no. times a day of week occurred in a date range

Author  Topic 

henderson.marty
Starting Member

6 Posts

Posted - 2008-08-28 : 07:11:46
Hi folks,

Having some diffs working with dates...

The structure is like this, a table holds a user id, day number (1-7) and time spent. Then for a specified date range I need to get the amount of times that day occured and the time spent.

So for a row in table a:
'martyh', 5, 60

And supplied a date range between now and 3 weeks ago, I would expect
'martyh', 5, 60, 28/08/2008
'martyh', 5, 60, 21/08/2008
'martyh', 5, 60, 14/08/2008

The only thing thats springing to mind at the moment is to create a temp or derived table with a list of the dates in it and join to it? Maybe there is a better way?

Hope you can help.

Thanks
Marty

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-08-28 : 07:14:15
sum the time and group by day number?

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

henderson.marty
Starting Member

6 Posts

Posted - 2008-08-28 : 07:50:28
thats not going to get me the date though that each day of week occurs on I think.
Go to Top of Page
   

- Advertisement -