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 |
|
Anonymous_writer
Starting Member
4 Posts |
Posted - 2007-11-21 : 14:50:53
|
| All,I am trying to design a graph to shows out build status for past 7-8 weeks. I have to write the SQL query first.After spending a good chunk of time, I could get some basic chart going. Problem is that I could give it a starting time till now (static) but I am not sure how to get the results for past 7-8 wekks. 1) What is a good approach for this since time is not static and it is changing. any example or piece of sql syntax is greately appreciated.Thaks in advance,aa- |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-11-21 : 14:55:01
|
| Did you use datediff and/or datepart function? |
 |
|
|
Anonymous_writer
Starting Member
4 Posts |
Posted - 2007-11-21 : 15:16:56
|
| HiThanks for responding. Yes, However I have to have a static starting and ending datess. I need from present time to go back 7 weeks - no matter when when present time is.SELECT datediff( month, '2007/07/19', '2006/07/23' )Thanks,aa- |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-11-21 : 15:36:36
|
| What day of the week does your week start on?Do you need to include the current week in your 7 weeks?CODO ERGO SUM |
 |
|
|
Anonymous_writer
Starting Member
4 Posts |
Posted - 2007-11-21 : 15:46:18
|
| Week can start on any day - it is not very important. However it should include current week as well.thanks,aa- |
 |
|
|
Koji Matsumura
Posting Yak Master
141 Posts |
Posted - 2007-11-21 : 23:49:35
|
| WHERE TargetDate BETWEEN DATEADD(week, -7, GETDATE()) AND GETDATE() |
 |
|
|
Anonymous_writer
Starting Member
4 Posts |
Posted - 2007-11-22 : 09:35:28
|
| Thank you all for Responding. |
 |
|
|
|
|
|