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 |
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, 60And 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/2008The 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.ThanksMarty |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-08-28 : 07:14:15
|
sum the time and group by day number?_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
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. |
 |
|
|
|
|
|
|