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 |
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2009-05-19 : 10:39:40
|
| I am trying to come up with a formula that pulls info on a week to week basis. I am using Sharepoint developer and he would like a drop down that has a specific date range already picked like this below....5/4/2009 - 5/8/20095/11/2009 - 5/15/20095/8/2009 - 5/22/20095/2/2009 - 5/29/2009I have this formula below, but it is only doing it for the current week. How can I get this to do what is above and also make it automated so it changes from week to week and month to month.(YEAR(bat_rcvd) = YEAR(GETDATE())) AND (DATEPART(wk, bat_rcvd) = DATEPART(wk, GETDATE()))I hope this makes sense because I am a little confuse. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-19 : 10:51:56
|
| [code]SET DATEFIRST 1SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) AS Start,DATEADD(wk,DATEDIFF(wk,0,GETDATE())+1,0)- 1 AS End[/code] |
 |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2009-05-19 : 10:59:26
|
Thanks how would I exclude Saturda and Sunday? Right now it is pulling 5/18 - 5/24quote: Originally posted by visakh16
SET DATEFIRST 1SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) AS Start,DATEADD(wk,DATEDIFF(wk,0,GETDATE())+1,0)- 1 AS End
|
 |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2009-05-19 : 11:01:15
|
| Never minde I did a -3 and it changed it to 5/18 to 5/22. Thanks for you help! |
 |
|
|
|
|
|
|
|